单步跟踪发现不执行
拖了个Menu控件到页面上,设置了OnMenuItemClick="NavigationMenu_MenuItemClick" 事件
F11单步跟踪却发现点击页面上的菜单项时跟本没有执行这个事件。
以下是代码:
<form id="form1" runat="server">
<h3>Menu Declarative Example</h3>
<!-- Use declarative syntax to create the -->
<!-- menu structure. Submenu items are -->
<!-- created by nesting them in parent menu -->
<!-- items. -->
<asp:menu id="NavigationMenu"
disappearafter="2000"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
font-names="Arial"
target="_blank"
runat="server" OnMenuItemClick="NavigationMenu_MenuItemClick"
>
<staticmenuitemstyle backcolor="LightSteelBlue"
forecolor="Black"/>
<statichoverstyle backcolor="LightSkyBlue"/>
<dynamicmenuitemstyle backcolor="Black"
forecolor="Silver"/>
<dynamichoverstyle backcolor="LightSkyBlue"
forecolor="Black"/>
<items>
<asp:menuitem navigateurl="list1.aspx"
text="Home"
tooltip="Home" >
<asp:menuitem navigateurl="list2.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="list3.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="list4.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="list5.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="list6.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="list7.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="list8.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="list9.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
return;
}
protected void NavigationMenu_MenuItemClick(object sender, MenuEventArgs e)
{
ViewState["url"] = NavigationMenu.SelectedItem. NavigateUrl.ToString();
}