This is a migrated thread and some comments may be shown as answers.

Menu in master page

1 Answer 87 Views
Menu
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 23 Oct 2009, 05:40 AM
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> 
 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 23 Oct 2009, 06:16 AM
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.
Tags
Menu
Asked by
L
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or