Menu in master page

2 posts, 1 answers
  1. L
    L avatar
    298 posts
    Member since:
    Apr 2008

    Posted 23 Oct 2009 Link to this post

    hi

    I have this error:

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated

    I don't seems to find any error in this code:

     

     


    Protected

     

    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

     

    Dim radmenu As RadMenu = DirectCast(Master.FindControl("RadMenu1"), RadMenu)  
     
    radmenu.FindItemByText("Home").Enabled = "false" 
     
    radmenu.FindItemByText("About Us").Enabled = "false" 
    End Sub
     
    <telerik:RadMenu ID="RadMenu1" Runat="server" Width="100%"   
     
    style="top: 0px; left: 0px" Skin="Black">  
     
    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
     
    <Items> 
     
    <telerik:RadMenuItem runat="server" Text="Home|" Font-Bold="true"   
     
    ForeColor="#FFFFC0" NavigateUrl="~/Home.aspx" > 
     
    </telerik:RadMenuItem> 
     
    <telerik:RadMenuItem runat="server" Text="About Us|" Font-Bold="true"   
     
    ForeColor="#FFFFC0" NavigateUrl="~/about.aspx">  
     
    </telerik:RadMenuItem> 
     
    </Items> 
     
    </telerik:RadMenu> 
     

     

  2. Answer
    Yana
    Admin
    Yana avatar
    4889 posts

    Posted 23 Oct 2009 Link to this post

    Hello,

    The text of the item is "Home |" , so radmenu.FindItemByText("Home") returns null, it cannot find the item. Please use it like this - radmenu.FindItemByText("Home |").

    Best regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top