This is a migrated thread and some comments may be shown as answers.

radmenu add click event to fire code behind code from code behind

5 Answers 238 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Code
Top achievements
Rank 1
Code asked on 19 Aug 2013, 01:33 PM
On my master page I have a telerek radmenu called "myMenu" see attached

On my aspx page that uses the master page I am trying to alter the link on the button "door" but the following wont work. Can you please help

Protected Sub Page_Load()
 
Dim H As RadMenu = DirectCast(myMenu.FindControl("House"), RadMenu)
Dim D As RadMenuItem = DirectCast(H.FindControl("door"), RadMenuItem)
 
D.click = LoadStuff()
 
End Sub
 
 
Private Sub LoadStuff()
 
'update something in vb.net
 
End Sub

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Aug 2013, 04:30 AM
Hi Code,

Please try the following code snippet that I have tried.

VB:
Protected Sub Page_Load(sender As Object, e As EventArgs)
    Dim menu As RadMenu = DirectCast(Master.FindControl("myMenu"), RadMenu)
    menu.ItemClick += New RadMenuEventHandler(AddressOf menu_ItemClick)
End Sub
 
Private Sub menu_ItemClick(sender As Object, e As RadMenuEventArgs)
    If e.Item.Text = "door" Then
        'update something in vb.net
        e.Item.NavigateUrl = "https://www.google.co.in/"
    End If
End Sub

Thanks,
Shinu.
0
Code
Top achievements
Rank 1
answered on 20 Aug 2013, 02:18 PM
Hi Shinu


Thanks for the reply but  this line over here gives an error.
menu.ItemClick += New RadMenuEventHandler(AddressOf menu_ItemClick)

It says that" menu.ItemClick" is not valid.  I dont see "ItemClick"

0
Shinu
Top achievements
Rank 2
answered on 21 Aug 2013, 01:28 PM
Hi Code,

I apologize for giving the incorrect code in VB. Please check the following updated code.

VB:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Dim RadMenu1 As RadMenu = DirectCast(Master.FindControl("myMenu"), RadMenu)
    AddHandler RadMenu1.ItemClick, AddressOf menu_ItemClick
End Sub
Protected Sub menu_ItemClick(ByVal sender As Object, ByVal e As RadMenuEventArgs)
   If e.Item.Text = "door" Then
      e.Item.NavigateUrl = "https://www.google.co.in/"
   End If
End Sub

Thanks,
Shinu.
0
Shwetha
Top achievements
Rank 1
answered on 03 Mar 2014, 11:06 PM
Hi, I need little help in attaching  radcontextmenu's "onclientitemclicking" event from code behind for vb.net. In datalist itemdatabound event I'm creating menuitems dynamically and attaching server side "Itemclick". Instead I want to use client side event to avoid postback. Please help. Thank you.
0
Shinu
Top achievements
Rank 2
answered on 04 Mar 2014, 04:38 AM
Hi Shwetha,

Please try the following VB code snippet which works fine at my end.

VB:
Protected Sub RadMenu1_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadMenuEventArgs)           Handles RadMenu1.ItemDataBound
...
        RadContextMenu1.OnClientItemClicking = "OnClientItemClicking"
...
    End Sub

Thanks,
Shinu.
Tags
Menu
Asked by
Code
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Code
Top achievements
Rank 1
Shwetha
Top achievements
Rank 1
Share this question
or