I have my navigation menu declared in the master class. I want to use it in the Default page but for some reason is not picking it up! Just to note the menu items are declared in the SiteMap file!
Here is the Master class menu I am trying to call:
<asp:Menu ID="NavigationSiteMapMenu" runat="server" CssClass="menu"
Orientation="Horizontal" DataSourceID="SiteMapDataSource1">
Here is the code I am using it in Default Page (In the Page Load Method) :
Dim testMenu As Menu = CType(Master.FindControl("NavigationSiteMapMenu"), Menu)
And here I am testing if it returns list of items but it doesn't the count is 0.
Dim test = testMenu.Items
Do you guys have any idea why my above code is not working, the logic seems perfect to me but clearly not to VB.NET!
This is the correct syntax:
Dim testMenu As Menu = CType(Master.FindControl("NavigationSiteMapMenu"), Menu)
My problem was that on one of the aspx pages I wasn't referencing the Master page. So please make sure the Master Page is referenced in all the required pages.
All the best and Good Luck!