问题
How do you call an onclick event from MenuItem since there is no OnClick property for MenuItem in ASP.NET?
Using NavigateUrl we can navaigate to a particular url but once I click on MenuItem it should trigger an event.
回答1:
Menu has MenuItem.MenuItemClick event, you can use that to do whatever you wanted with onclick.
回答2:
You can use the Menu.MenuItemClick event of the Menu that contains your menu item:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.menuitemclick.aspx
<asp:Menu runat="server" ID="MyMenu" onmenuitemclick="MyMenu_MenuItemClick" ... >
...
</asp:Menu>
Clicking on any menu item that does not have the NavigateUrl property set will cause the page to be postback and the Menu.MenuItemClick event handler to be executed.
来源:https://stackoverflow.com/questions/11396321/how-do-you-call-an-onclick-event-from-a-menuitem-in-asp-net