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

Howto rebind RadContextMenu before showing

3 Answers 95 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 03 Feb 2011, 12:21 PM
Hello,

I need a solution to completly rebind the items of the context menu on runtime at server side when user right-clicks.

Items are currently bound with following code. Now I like to bind the items not in page_load, but when user right-clicks, because items are generated in future in a separate business logic on another server and they can change between page_loads.
 
I have tried a server callback event on client event "OnClientShowing"; it works but unfortunately no changes can be done here. The context menu will not change.

Does anybody find a solution for that?

Thanks in advance

RenĂ© 

<telerik:RadContextMenu ID="RadContextMenu1" runat="server">
    <Targets>
      <telerik:ContextMenuControlTarget ControlID="TextBox1" />
      <telerik:ContextMenuControlTarget ControlID="Label1" />
      <telerik:ContextMenuControlTarget ControlID="Image1" />
    </Targets>                
    <Items>
    </Items>
</telerik:RadContextMenu>


    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            RadContextMenu1.DataTextField = "Text"
            RadContextMenu1.DataNavigateUrlField = "Url"
            RadContextMenu1.DataFieldID = "ID"
            RadContextMenu1.DataFieldParentID = "ParentID"
            RadContextMenu1.DataSource = GenerateSiteData()
            RadContextMenu1.DataBind()
        End If
    End Sub
  
    Private Function GenerateSiteData() As ArrayList
        Dim siteData As New ArrayList()
        siteData.Add(New SiteDataItem(1, Nothing, "All Sites", ""))
        siteData.Add(New SiteDataItem(2, 1, "Search Engines", ""))
        siteData.Add(New SiteDataItem(3, 1, "News Sites", ""))
        siteData.Add(New SiteDataItem(4, 2, "Yahoo", "http://www.yahoo.com"))
        siteData.Add(New SiteDataItem(5, 2, "MSN", "http://www.msn.com"))
        siteData.Add(New SiteDataItem(6, 2, "Google", "http://www.google.com"))
        siteData.Add(New SiteDataItem(7, 3, "CNN", "http://www.cnn.com"))
        siteData.Add(New SiteDataItem(8, 3, "BBC", "http://www.bbc.co.uk"))
        siteData.Add(New SiteDataItem(9, 3, "FOX", "http://www.foxnews.com"))
        Return siteData
    End Function
  
Public Class SiteDataItem
    Private _text As String
    Private _url As String
    Private _id As Integer
    Private _parentId As Integer
    Public Property Text() As String
        Get
            Return _text
        End Get
        Set(ByVal value As String)
            _text = value
        End Set
    End Property
    Public Property Url() As String
        Get
            Return _url
        End Get
        Set(ByVal value As String)
            _url = value
        End Set
    End Property
    Public Property ID() As Integer
        Get
            Return _id
        End Get
        Set(ByVal value As Integer)
            _id = value
        End Set
    End Property
    Public Property ParentID() As Integer
        Get
            Return _parentId
        End Get
        Set(ByVal value As Integer)
            _parentId = value
        End Set
    End Property
    Public Sub New(ByVal id As Integer, ByVal parentId As Integer, ByVal text As String, ByVal url As String)
        _id = id
        _parentId = parentId
        _text = text
        _url = url
    End Sub
End Class

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 07 Feb 2011, 09:38 AM
Hi Rene,

Here I have attached a sample project with a possible solution to your issue and a helps article if you need more information about how AJAX Manager works.

Greetings,
Kate
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Rene
Top achievements
Rank 1
answered on 07 Feb 2011, 03:49 PM
Thanks a lot for the sample.
But I'm not sure how to use it in my case.

The context menu is used in a web user control and all logic about that should be encapsulated in this. So I have only RadAjaxManagerProxy on the WebUserControl's page, but RadAjaxManagerProxy does not have the event AjaxRequest?? Sorry, but I'm relatively new in RadControls, ASP and VB.NET, and you may help me a little more... :-)

cheers

René
0
Kate
Telerik team
answered on 08 Feb 2011, 12:39 PM
Hi Rene,

Here is more information about RadAjaxManagerProxy that
would bring more light to the matter.

Best wishes,
Kate
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Menu
Asked by
Rene
Top achievements
Rank 1
Answers by
Kate
Telerik team
Rene
Top achievements
Rank 1
Share this question
or