...

View Full Version : .Net Menu Control, Menu Item has a "/" in the title, causing exception



pmcs
03-21-2012, 01:32 AM
Hi,

In my list of menus on the .aspx page, I have a menu title that has a "/" in the title("Patient Selection/Worklist").

ASPX Page:
<asp:MenuItem Text="Tools" ToolTip="Tools">
<asp:MenuItem Text="Patient Selection/Worklist" ToolTip="Patient Selection/Worklist" NavigateUrl="~/Web/PatientSelection.aspx"/>

Code Behind Page:
if (!_userSession.DbUser.IsPrimaryReviewerSomewhere)
{
MenuItem item = MainNavigationMenu.FindItem("Tools/Patient Selection/Worklist");
item.Parent.ChildItems.Remove(item);

On the code behind, I try and control if that menu item appears via the IF clause.
It doesn't like the second "/" in the menu title and throws "Object reference not set to an instance of an object exception.
I think that it interprets the 2nd "/" as another menu level("Tools/Patient Selection/Worklist")).
I have tried using the special character (&#47) to escape out the 2nd "/", but it doesn't work.

Any idea how to handle the 2nd / in the menu item title?


Thank You in advance,

Eric

pmcs
03-21-2012, 04:07 AM
Figured it out…



You have to use pathseparator in the aspx page

to designate the separation character in the code behind.



<asp:menu id="NavigationMenu"

staticdisplaylevels="2"

staticsubmenuindent="10"

orientation="Vertical"

pathseparator=","

runat="server">

More info:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.pathseparator.aspx

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum