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

6 posts, 0 answers
  1. Code
    Code avatar
    9 posts
    Member since:
    Aug 2013

    Posted 19 Aug 2013 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Aug 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Code
    Code avatar
    9 posts
    Member since:
    Aug 2013

    Posted 20 Aug 2013 Link to this post

    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"

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Aug 2013 Link to this post

    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.
  6. Shwetha
    Shwetha avatar
    12 posts
    Member since:
    Nov 2013

    Posted 03 Mar 2014 in reply to Shinu Link to this post

    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.
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2014 in reply to Shwetha Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017