Prevent click event on menu item from reloading in asp.net

Dec 15 2015 1:06 PM

I am using ASP Menu control with a collection of sub menu items. If user clicks on main menu item it reloads and the screen makes a postback. It irritates the user when clicks on main menu as it is only to list out the categories. How to prevent the loading of page when user clicks on main menu item I tried some code using javascript but its not working.

My ASP menu control:

<asp:Menu ID="mini" OnMenuItemClick="mini_MenuItemClick" runat="server" Orientation="Horizontal" >
 <Items> <asp:MenuItem Text="Items">
 <asp:MenuItem Text="sdaad" Value="1" > 
<asp:MenuItem Text="MenuSub1" Value="MenuSub1" >
</asp:MenuItem> 
<asp:MenuItem Text="MenuSub2" Value="MenuSub2" ></asp:MenuItem>
 </asp:MenuItem> <asp:MenuItem Text="qwerty" Value="qwerty"> 
<asp:MenuItem Text="MenuSub" Value="MenuSub"></asp:MenuItem>
 </asp:MenuItem> </asp:MenuItem> </Items> </asp:Menu>
 Javascript to handle the issue:
 
function OnMenuItemClick(s, e) { 
if (e.item.name == "Items")        
 e.processOnServer = false; }
 
 
 
 

Answers (1)