如何在 System.Web.UI.WebControls.Menu 中选择菜单项时传递命令参数
我有一个菜单。当用户单击菜单时,我需要传递命令参数。这是怎么做到的?
这是代码
<asp:Menu ID="NoticeManagerMenu" runat="server" Orientation="Horizontal" OnMenuItemClick="NoticeManagerMenu_MenuItemClick">
<StaticMenuStyle HorizontalPadding="0px" VerticalPadding="0px" />
<StaticMenuItemStyle BackColor="#C0C0FF" />
<StaticSelectedStyle BackColor="#C0C0FF" BorderColor="#C0C0FF" />
<StaticHoverStyle BackColor="Silver" />
<Items>
<asp:MenuItem Text="List"></asp:MenuItem>
<asp:MenuItem Text="Insert"></asp:MenuItem>
</Items>
</asp:Menu>
在后面的代码中,我希望像这样使用
protected void NoticeManagerMenu_MenuItemClick(object sender, MenuEventArgs e)
{
if (e.CommandArgument.Equals("Update"))
{
}
else
{
}
}
提前致谢..
I have a Menu. When user clicks on the menu , I need to pass a command argument. How is that done ?
This is the code for
<asp:Menu ID="NoticeManagerMenu" runat="server" Orientation="Horizontal" OnMenuItemClick="NoticeManagerMenu_MenuItemClick">
<StaticMenuStyle HorizontalPadding="0px" VerticalPadding="0px" />
<StaticMenuItemStyle BackColor="#C0C0FF" />
<StaticSelectedStyle BackColor="#C0C0FF" BorderColor="#C0C0FF" />
<StaticHoverStyle BackColor="Silver" />
<Items>
<asp:MenuItem Text="List"></asp:MenuItem>
<asp:MenuItem Text="Insert"></asp:MenuItem>
</Items>
</asp:Menu>
In the code behind, I wish to use like this
protected void NoticeManagerMenu_MenuItemClick(object sender, MenuEventArgs e)
{
if (e.CommandArgument.Equals("Update"))
{
}
else
{
}
}
Thanks in Advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CommandName
和CommandArgument
属性似乎是只读的。您可以尝试比较菜单项的Text
。CommandName
andCommandArgument
properties seem to be read-only. You might try to compare theText
of your menu item.您尝试过 Value 属性吗?
http://msdn.microsoft.com/en-我们/库/ecs0x9w5(v=VS.80).aspx
Did you tried Value attribute?
http://msdn.microsoft.com/en-us/library/ecs0x9w5(v=VS.80).aspx