I try to reach classic navigation menu item from website in c#, asp.net. My navigation menu like that :
How can I reach My Profile NavigateURL and change it? I tried this but mi
is null
:
Menu m = (Menu)Master.FindControl("NavigationMenu");
MenuItem mi = new MenuItem();
mi = m.FindItem("Account,My Profile");
mi.NavigateUrl = "~/MyProfile.aspx?u开发者_运维知识库serid=" + userid;
Please help :(
This should work:
var menu = (Menu)Master.FindControl("NavigationMenu");
var menuItem = menu.FindItem("Account" + menu.PathSeparator + "My Profile");
menuItem.NavigateUrl = "~/MyProfile.aspx?userid=" + 123;
The default PathSeparator
is a slash mark (/).
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.pathseparator.aspx
If you didn't override it, then you can also use path Account/My Profile
精彩评论