4

I try to reach classic navigation menu item from website in c#, asp.net. My navigation menu like that :

menu

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?userid=" + userid;

Please help :(

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.