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

JScript error with adding menu items in codebehind?

2 Answers 58 Views
Menu
This is a migrated thread and some comments may be shown as answers.
TSCGlobal
Top achievements
Rank 1
TSCGlobal asked on 09 Dec 2010, 03:48 PM
I was recently working with adding menu items in a vb.net code behind based on a user's role.  The item was added to the menu, but the code gave birth to a weird error that I have no idea what it means, where it is, or how to address.  Any help is appreciated.

Here's the code behind;
'Determine user access, and load controls accordingly
If Roles.IsUserInRole(UserID, "Loss Prevention") = True Then
 
    'Create menu items
    Dim item As RadMenuItem = New RadMenuItem("Loss Prevention")
    Dim ChildItem As RadMenuItem = New RadMenuItem("I.P. Search")
 
    'assign all necessary menu item properties
    ChildItem.NavigateUrl = "~/LossPrevention/IPSearch.aspx"
    ChildItem.ImageUrl = "~/App_Themes/PanBlue/icons/SearchIcon1.png"
 
    'add menu items
    RadMenu1.Items.Add(item)
    item.Items.Add(ChildItem)
End If

When I run this app, I get a error that says; Microsoft JScript runtime error: 'undefined' is null or not an object (screen shot attached)

The best I can tell, this is a generated telerik code file that is screwing up somehow.  Any ideas on how to fix this?  I can't deploy the app with this issue.

2 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 09 Dec 2010, 08:32 PM
Hello beemer,

I doubt this will help, but I would suggest adding the child item to the parent before adding it to the menu. Even through you have a reference to the parent item, it's not going to add the child item because you already added the parent item to the menu with no child items.
0
TSCGlobal
Top achievements
Rank 1
answered on 10 Dec 2010, 05:30 PM
Thanks for the suggestion, however I did find the issue.  I had commented out a control (for troubleshooting purposes), but did not remove/comment out the control registry at the page directive.  Removing both also removed the issue.  Who would've thunk? lol.
Tags
Menu
Asked by
TSCGlobal
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
TSCGlobal
Top achievements
Rank 1
Share this question
or