Context Menu Created Server Side

2 posts, 0 answers
  1. John Reid
    John Reid avatar
    28 posts
    Member since:
    Mar 2006

    Posted 13 Feb 2009 Link to this post

    Hi -

    I created a context menu completely on the server side (with code below). Now I need to add the click events (Edit and Delete) to open a rad window to a new url and have no idea how to do this.

    Can anyone help!!

    Thanks in advance


    Dim

     

    editMenu As New RadContextMenu

     

    editMenu.ID =

    "editMenu"

     

    editMenu.Attributes(

    "style") = "top: 65px; left: 10px"

     

    editMenu.Skin =

    "Vista"

     

     

    Dim editZone As New Telerik.Web.UI.ContextMenuControlTarget

     

    editZone.ControlID =

    "contextElement"

     

    editMenu.Targets.Add(editZone)

    editMenu.CollapseAnimation.Type = AnimationType.OutQuint

    editMenu.CollapseAnimation.Duration = 200

     

    Dim itemEdit As New RadMenuItem

     

    itemEdit.Text =

    "Edit"

     

    editMenu.Items.Add(itemEdit)

    Controls.Add(editMenu)

     

    Dim itemDelete As New RadMenuItem

     

    itemDelete.Text =

    "Delete"

     

    editMenu.Items.Add(itemDelete)

    Controls.Add(editMenu)

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Feb 2009 Link to this post

    Hello John,

    You can add the ItemClick event handler for the menu as shown below:
    cs:
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
         Dim editMenu As New RadContextMenu() 
         editMenu.ID = "editMenu" 
         editMenu.Attributes("style") = "top: 65px; left: 10px" 
         editMenu.Skin = "Vista" 
         Dim editZone As New Telerik.Web.UI.ContextMenuControlTarget() 
         editZone.ControlID = "contextElement" 
         editMenu.Targets.Add(editZone) 
         editMenu.CollapseAnimation.Type = AnimationType.OutQuint 
         editMenu.CollapseAnimation.Duration = 200 
         AddHandler editMenu.ItemClick, AddressOf editMenu_ItemClick 
         Dim itemEdit As New RadMenuItem() 
         itemEdit.Text = "Edit" 
         editMenu.Items.Add(itemEdit) 
         Controls.Add(editMenu) 
         Dim itemDelete As New RadMenuItem() 
         itemDelete.Text = "Delete" 
         editMenu.Items.Add(itemDelete) 
         Controls.Add(editMenu) 
     End Sub 
     
     Private Sub editMenu_ItemClick(ByVal sender As Object, ByVal e As RadMenuEventArgs) 
         If e.Item.Text = "Edit" Then 
             'redirect page 
         ElseIf e.Item.Text = "Delete" Then 
             ' redirect page 
         End If 
     End Sub 

    Thanks
    Princy.
Back to Top