+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Menu control throws NullReferenceException

Menu control throws NullReferenceException

5 posts, 0 answered
  1. El Barto
    El Barto avatar
    42 posts
    Registered:
    28 Apr 2008
    23 Dec 2014
    Link to this post
    I've updated from 6.2 to7.3.5610.0. After this update the normal ASP.NET menu control is no longer working. I've created a new empty sitefinity project and created a masterpage with a ASP.NET menu control. This results in the same error. 
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="SitefinityWebApp.Site1" %>
      
    <!DOCTYPE html>
      
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"></asp:Menu>
                <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html>
      
     
    [NullReferenceException: Object reference not set to an instance of an object.]
       System.Web.UI.WebControls.Menu.DataBindRecursive(MenuItem node, IHierarchicalEnumerable enumerable) +1932
       System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +315
       System.Web.UI.WebControls.Menu.PerformDataBinding() +124
       System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +102
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
       System.Web.UI.WebControls.Menu.DataBind() +4
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
       System.Web.UI.WebControls.Menu.EnsureDataBound() +34
       System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) +24
       System.Web.UI.Control.PreRenderRecursiveInternal() +83
       System.Web.UI.Control.PreRenderRecursiveInternal() +155
       System.Web.UI.Control.PreRenderRecursiveInternal() +155
       System.Web.UI.Control.PreRenderRecursiveInternal() +155
       System.Web.UI.Control.PreRenderRecursiveInternal() +155
       System.Web.UI.Control.PreRenderRecursiveInternal() +155
       System.Web.UI.Control.PreRenderRecursiveInternal() +155
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

     
  2. Kristian Smilenov
    Kristian Smilenov avatar
    32 posts
    Registered:
    18 Mar 2015
    26 Dec 2014
    Link to this post
    Hello Bart,

    Thank you for contacting us.

    I reproduces the issue on Sitefinity 7.3 on my side and verified that in Sitefinity 6.2 the same case was working. However, when I moved the Menu control and the SiteMapDataSource out of the asp:ContentPlaceHolder everything was okay.

    <div id="Content">
         Menu:
        <asp:Menu ID="Menu1" runat="server" RenderingMode="Table"></asp:Menu>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
     
        <asp:ContentPlaceHolder id="Content" runat="server">
        </asp:ContentPlaceHolder>
    </div>

    I am setting the Data Source of the Menu on Page_Load like this: 

    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.SiteMapDataSource1 = new SitefinitySiteMapDataSource();
            this.SiteMapDataSource1.Provider = SiteMapBase.GetSiteMapProvider("FrontendSiteMap");
            this.SiteMapDataSource1.ShowStartingNode = false;
            this.Menu1.DataSource = this.SiteMapDataSource1;
            this.Menu1.DataBind();
        }
    }

    I will contact our developers after the holidays to check if this behaviour is an intended change or a bug.

    Regards,
    Kristian Smilenov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. El Barto
    El Barto avatar
    42 posts
    Registered:
    28 Apr 2008
    28 Dec 2014 in reply to Kristian Smilenov
    Link to this post

    Hi Kristian,

    Thanks for looking into this. I cannot easily move the menu control outside the contentplaceholder as I'm using nested masterpages.

    I'm looking forward to the developer's response.

     

    Regards,

     

    Bart Vanlier

  4. El Barto
    El Barto avatar
    42 posts
    Registered:
    28 Apr 2008
    11 Jan 2015
    Link to this post

    Any news regarding this issue?

    Another issue I've got, probably related to this, is when i try to set StartingNodeUrl I get an ArgumentException telling me I'm not allowed to set the relative path "~/Custom/Controls/WebFront/". I've tried several setting several url's but I keep getting this exception.

  5. El Barto
    El Barto avatar
    42 posts
    Registered:
    28 Apr 2008
    13 Jan 2015
    Link to this post

    There seems to be something wrong with my database. When I delete all pages and create new ones, the problem goes away.

    Any help would be greatly appreciated as recreating all pages is not really an option.

5 posts, 0 answered