Click here to Skip to main content
15,918,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am using Asp.Net Menu control in my master page. I am getting the data to bind the menu is from Sql Server Database.

If I select a sub item from menu then parent item must be showed as selected.
To do this functionality i tried to write code in "MenuItemClick" Event. But its not firing.

Appreciate your support.

Thanks,
Rajesh
Posted

Are you using the NavigateUrl property? If you set the NavigateUrl while creating the menu items, the page will navigate instead of firing click event handler.

When the user clicks a menu item, the Menu control can either navigate to a linked Web page or simply post back to the server. If the NavigateUrl property of a menu item is set, the Menu control navigates to the linked page; otherwise, it posts the page back to the server for processing.
 
Share this answer
 
Try using the inline event handler assignment within the asp:Menu tag like:
ASP.NET
<asp:Menu OnMenuItemClick="MenuEventHandler" />


or you can just do that inside your code behind .vb or .cs like:

C#
menu.OnMenuItemClick += Menu_MenuItemClick; // Attach event handler programatically

private void Menu_MenuItemClick(Object sender, EventArgs e)// MenuItemClick event handler
{
  //Your code...
}


Note: The code above is a C# code. You can make use of AddHandler for VB, to attach an event handler in code.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900