AJAX Updating control after UserControl event

2 posts, 0 answers
  1. Graham
    Graham avatar
    7 posts
    Member since:
    Feb 2008

    Posted 26 Feb 2010 Link to this post

    I have a page with a usercontrol on (MyUserControl). MyUserControl is able to raise a "custom" event which is handled by the page code-behind.

    Both MyUserControl and page have RadAjaxManagerProxy controls (the main page is controlled by a master page.)

    Here is the process:

    MyUserControl initiates an ajaxrequest through client-side script:

           function Refresh() {             
               $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest('Refresh');  
           } 

    This is then dealt with by MyUserControl in its code behind.

    Private Sub Control_Load(ByVal Sender As ObjectByVal e As EventArgs) Handles MyBase.Load   
          
        Dim Manager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)   
        AddHandler Manager.AjaxRequest, AddressOf AjaxManager_AjaxRequest  
     
     
    End Sub 
     
    Protected Sub AjaxManager_AjaxRequest(ByVal sender As ObjectByVal e As AjaxRequestEventArgs)     
        
                Select Case e.Argument.ToString()     
        
                    Case "Refresh"    
        
                        RaiseSaved()     
        
                        Refresh()     
        
                End Select    
        
            End Sub    


    For info, the RaiseSaved sub call is for raising the MyUserControl OnUpdated event. The Refresh() sub call just refreshes controls in MyUserControl.

    The event is then handled by the code behind in the main page:
    Public Sub MyUserControl_Updated(ByVal Sender As ObjectByVal e As EditorUpdatedEventArgs) Handles MyUserControl.OnUpdated     
       
                'Check to see if event is being handled/firing  
                MyUserControl.Visible = False 
     
                'Update a control on the main page   
                RebindStatus.RebindStatus = True    
        
            End Sub    
     

    The event is definitely firing as the "MyUserControl.Visible = False" statement hides MyUserControl.

    However, the control on the main page (RebindStatus) is not being updated and this is the problem.  I need to be able to update this (and any other) control on the main page.

    For info, RebindStatus is another usercontrol which has a custom property that updates a label in the RebindStatus control.

    I have probably got the Ajax settings incorrect. For the RadAjaxManagerProxy on MyUserControl:

    <telerik:RadAjaxManagerProxy ID="WindowAjaxManagerProxy" runat="server">  
        <AjaxSettings>  
            <telerik:AjaxSetting AjaxControlID="MasterPageAjaxManager">  
                <UpdatedControls>  
                    <telerik:AjaxUpdatedControl ControlID="MyUserControl" />  
                    <telerik:AjaxUpdatedControl ControlID="RebindStatus" />     
                </UpdatedControls>  
            </telerik:AjaxSetting>  
                </UpdatedControls>  
        </AjaxSettings>   
    </telerik:RadAjaxManagerProxy> 
    NB. MasterPageAjaxManager is the name of the RadAjaxManager on the MasterPage controlling the main page.

    For the RadAjaxManagerProxy on the main page:
    <telerik:RadAjaxManagerProxy ID="WindowAjaxManagerProxy" runat="server">  
            <AjaxSettings>  
                <telerik:AjaxSetting AjaxControlID="MyUserControl" EventName="OnUpdated">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="RebindStatus" />                 
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
                <telerik:AjaxSetting AjaxControlID="MyUserControl">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="MyUserControl" />   
                        <telerik:AjaxUpdatedControl ControlID="RebindStatus" />            
                        <telerik:AjaxUpdatedControl ControlID="MainPageAjaxManager" />            
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
                <telerik:AjaxSetting AjaxControlID="MainPageAjaxManager">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="BookingEditor" />  
                        <telerik:AjaxUpdatedControl ControlID="MainPageAjaxManager" />  
                        <telerik:AjaxUpdatedControl ControlID="RebindStatus" />                      
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
                <telerik:AjaxSetting AjaxControlID="RebindStatus">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="RebindStatus" />                      
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
            </AjaxSettings>   
        </telerik:RadAjaxManagerProxy>  

    How can I update the RebindStatus control from the event raised by MyUserControl? To confirm, the OnUpdated event is firing, but no controls on the main page can be updated from this event.

    thanks

    Graham.
  2. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 01 Mar 2010 Link to this post

    Why not try removing the MainPageAjaxManager control from the UpdatedControls list. It's not needed there and it may be the reason it doesn't work.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top