HELP for MENU

kunal.kb

Member
Joined
Sep 8, 2005
Messages
21
Programming Experience
Beginner
hello ppl......
i need help for menu click......
i have created a menu dynamically.....
now i am not able to capture the cilck event of menu item...
i want to capture the value of the menu item..and according to this value the page will be redirected.......
can some one help me......
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,412
Location
Norway
Programming Experience
10+
Use AddHandler to subscribe to the MenuItemClick event and point it to the event handler method:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
  addmenu()
End Sub
 
Private Sub addmenu()
  Dim m As New Menu
  Dim mi As New MenuItem("Go to Page2", "[SIZE=2][COLOR=black]Default2.aspx[/COLOR][/SIZE]")
  m.Items.Add(mi)
  form1.Controls.Add(m)
  AddHandler m.MenuItemClick, AddressOf DynMenu_MenuItemClick
End Sub
 
Protected Sub DynMenu_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs)
[SIZE=2]  Response.Redirect(e.Item.Value)
[/SIZE]End Sub

 
Top Bottom