Asp.Net菜单控件的“MenuItemClick”事件没有解雇 [英] Asp.Net Menu Control's "MenuItemClick" Event not firing

查看:127
本文介绍了Asp.Net菜单控件的“MenuItemClick”事件没有解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我在母版页中使用Asp.Net菜单控件。我获取绑定菜单的数据来自Sql Server数据库。



如果我从菜单中选择一个子项,那么父项必须显示为选中状态。

为了实现这个功能,我试图在MenuItemClick事件中编写代码。但它没有开火。



感谢你的支持。



谢谢,

Rajesh

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

推荐答案

您使用的是NavigateUrl属性吗?如果在创建菜单项时设置NavigateUrl,页面将导航而不是触发单击事件处理程序。



当用户单击菜单项时,Menu控件可以导航到链接的网页或只是回发到服务器。如果设置了菜单项的NavigateUrl属性,则Menu控件将导航到链接页面;否则,它会将页面发回服务器进行处理。
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.


试试这个------- http://www.c-sharpcorner.com/UploadFile/4e2862/dynamically-creating-menus-and-submenus- items-to-web-forms / [ ^ ]



根据用户权限从数据库生成菜单 [ ^ ]
try this -------http://www.c-sharpcorner.com/UploadFile/4e2862/dynamically-creating-menus-and-submenus-items-to-web-forms/[^]

Generating menu from database according to user privilege[^]


尝试在asp:Menu标签中使用内联事件处理程序分配,例如:

Try using the inline event handler assignment within the asp:Menu tag like:
<asp:Menu OnMenuItemClick="MenuEventHandler" />





或您可以在.vb或.cs之后的代码中执行此操作,例如:





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

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

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





< b style =color:Red>注意:上面的代码是C#代码。您可以使用VB的 AddHandler ,在代码中附加事件处理程序。



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


这篇关于Asp.Net菜单控件的“MenuItemClick”事件没有解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆