Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using a menu on my master page in website for navigation.

The menu have been added within the right arrow option on menu item.

The problem is that I have to use the menu click event, which is not firing probably due to the use of navigate url event.

Now at this stage of project I cannot rework on creating dynamic menus and I have also created the rights management system according to the current menu system.

Is their any work around?

Pls suggest. A bit urgent. Thanks..

Atul

Starting part of code for reference. The whole menu is quite long and may not be useful to be posted.

XML
<asp:Menu ID="Menu1" runat="server" BackColor="Silver" Font-Names="Andalus" Font-Size="Large" ForeColor="Black" style="font-size: medium" Orientation="Horizontal" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Width="100%" Font-Bold="True" CssClass="newStyle1" Font-Underline="False" OnMenuItemClick="Menu1_MenuItemClick"  >
    <Items>
        <asp:MenuItem Text="Masters" Value="Masters" >
            <asp:MenuItem Text="Plant" Value="Mill" NavigateUrl="~/APP_Pages/Material/Masters/MillMaster.aspx">
            </asp:MenuItem>
Posted

1 solution

Hi,

If you want to perform a postback (to hook into the menu item click event), you will need to remove the address from the menus NavigateUrl property.

If you remove the NavigateUrl property, you can perform the navigation (after you've ran what ever else needs to be done in your menu item click event), by identifying the item that was clicked, and redirecting to the appropriate target page.

I'm rusty with VB these days ... but in C#, something like this should work:
C#
protected void mnuNavMenu_MenuItemClick(object sender, MenuEventArgs e)
  {
    switch (e.Item.Text)
    {
    case "Home":
      Response.Redirect("~/");
      break;
    case "Masters":
      Response.Redirect("~/APP_Pages/Material/Masters/MillMaster.aspx");
      break;
    ...
    ...
    ...
    default:
      Response.Redirect("~/");
      break;
    }
  }


If you're stuck converting to VB, let me know where and I'll have a look.

[edit] Adding VB Conversion [/edit]
VB
Protected Sub mnuNavMenu_MenuItemClick(sender As Object, e As MenuEventArgs)
	Select Case e.Item.Text
		Case "Home"
			Response.Redirect("~/")
			Exit Select
		Case "Masters"
			Response.Redirect("~/APP_Pages/Material/Masters/MillMaster.aspx")
			Exit Select
		Case Else
			Response.Redirect("~/")
			Exit Select
	End Select
End Sub


... Hope it helps.
 
Share this answer
 
v2
Comments
atul sharma 5126 25-Feb-15 19:20pm    
Thanks dear. It worked perfectly.
hypermellow 26-Feb-15 4:04am    
Happy to help, thanks for letting me know :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900