More in this section
Forums / Developing with Sitefinity / AjaxRequest MasterPage to content control

AjaxRequest MasterPage to content control

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Chanan Zass
    Chanan Zass avatar
    123 posts
    Registered:
    21 Aug 2012
    03 May 2011
    Link to this post
    Greetings,

    We run a user control within a master page.
    User control includes a RadGrid, a TreeView, a RadWindowManager and a RadAjaxLoadingPanel.

    AjaxManager is set in the MasterPage.

    In the User Control's Page_Load we include the following:

    Dim AjaxManager As RadAjaxManager = CType(Page.Master.FindControl("RadAjaxManager1"), RadAjaxManager)
    AjaxManager.AjaxSettings.AddAjaxSetting(RadGrid1, RadGrid1, RadAjaxLoadingPanel1)
    AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, RadGrid1, RadAjaxLoadingPanel1)

    In the User Control ascx, there's a javascript function called upon window closing:

    function OnClientClose(oWnd) {
         var ram1 = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
         if (ram1 != null) {
              ram1.ajaxRequest("Rebind");
         
     }

    My question is where should I place the AjaxRequest code:

    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            If e.Argument = "Rebind" Then
                RadGrid1.Rebind()
      
            ElseIf e.Argument = "RebindAndNavigate" Then
                RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
                RadGrid1.Rebind()
            End If
        End Sub

    We've tried placing it in the master page and in the user control. None works following a window closing.
    Rest works fine on the page.

    Thanks in advance for a clue.

  2. Chanan Zass
    Chanan Zass avatar
    123 posts
    Registered:
    21 Aug 2012
    04 May 2011
    Link to this post
    Let me answer myself, for posterity's sake.

    MasterPage:
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>

    Content Control:
    Insert
    - RadAjaxLoadingPanel
    - RadWindowManager
    - Javascript to manage opening and closing windows (enclosed within RadCodeBlock)

    Content Control's code behind (VB):
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim manager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)
            manager.AjaxSettings.AddAjaxSetting(RadGrid1, RadGrid1, RadAjaxLoadingPanel1)
            manager.AjaxSettings.AddAjaxSetting(manager, RadGrid1, RadAjaxLoadingPanel1)
            AddHandler manager.AjaxRequest, AddressOf manager_AjaxRequest
    End Sub
      
    Protected Sub manager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            If e.Argument = "Rebind" Then
                RadGrid1.Rebind()
      
            ElseIf e.Argument = "RebindAndNavigate" Then 
                RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
                RadGrid1.Rebind()
            End If
     End Sub

    It works.
2 posts, 0 answered