javascript 如何从 ASP.NET 中的 MenuItem 调用 onClick 事件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11396321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you call an onClick event from a MenuItem in ASP.NET?
提问by Learner
How do you call an onclick
event from MenuItem
since there is no OnClick
property for MenuItem
in ASP.NET?
由于在 ASP.NET 中没有属性,您如何调用onclick
事件?MenuItem
OnClick
MenuItem
Using NavigateUrl
we can navaigate to a particular url but once I click on MenuItem
it should trigger an event.
使用NavigateUrl
我们可以导航到特定的 url 但一旦我点击MenuItem
它应该触发一个事件。
回答by Ashwin Singh
Menu has MenuItem.MenuItemClick
event, you can use that to do whatever you wanted with onclick
.
菜单有MenuItem.MenuItemClick
事件,你可以用它来做任何你想做的事情onclick
。
回答by Joe
You can use the Menu.MenuItemClick
event of the Menu that contains your menu item:
您可以使用Menu.MenuItemClick
包含您的菜单项的 Menu 事件:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.menuitemclick.aspx
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.
单击没有NavigateUrl
设置属性的任何菜单项将导致页面回发并执行Menu.MenuItemClick
事件处理程序。