change radmenu click events

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

    Posted 26 Aug 2013 Link to this post

    Hi have a rad menu that is set in the master page and has all the url/links added there.

    I am trying to change two of the radMenuitems navigation links from my aspx page code behind
    D) replace the link with a javascript click event.
    E) when you click then fire a void click event

    Protected Sub Page_Load(sender As Object, e As EventArgs)
      Dim rmenu As RadMenu = DirectCast(Master.FindControl("mymenu"), RadMenu)
      Dim D As RadMenuItem = DirectCast(rmenu.FindControl("dogs"), RadMenuItem)
      Dim E As RadMenuItem = DirectCast(rmenu.FindControl("cats"), RadMenuItem)
      D.NavigateUrl = nothing
      E.NavigateUrl = nothing
    = "alert('you clicked on dogs')" = Button1_Click
    End Sub
    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        'do this for cats only
    End Sub

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

    Posted 26 Aug 2013 Link to this post

    Hi Code,

    Try the following code snippet to fire a javascript client event on clicking one item of a RadMenu and server side button click event on another item of the same RadMenu.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        radmenu1 = DirectCast(Master.FindControl("RadMenu1"), RadMenu)
        AddHandler radmenu1.ItemClick, AddressOf radmenu1_ItemClick
    End Sub
    Protected Sub radmenu1_ItemClick(sender As Object, e As RadMenuEventArgs)
        If e.Item.Text = "dogs" Then
            Dim ShowClick As String = "ShowClick();"
            ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "ShowClick", ShowClick, True)
        End If
        If e.Item.Text = "cats" Then
            RadButton1.Click += New EventHandler(RadButton1_Click)
            RadButton1_Click(Me, e)
        End If
    End Sub
    Protected Sub RadButton1_Click(sender As Object, e As EventArgs)
        Response.Write("<script>alert('Server Side');</script")
    End Sub

    <script type="text/javascript">
        function ShowClick() {
            alert("Client Side");

Back to Top