Menu control throws NullReferenceException
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> <html xmlns="http://www.w3.org/1999/xhtml"><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) +974Hello 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>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(); 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
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.
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.