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

AJAX Updating control after UserControl event

1 Answer 105 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 1
Graham asked on 26 Feb 2010, 10:14 AM
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.

1 Answer, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 01 Mar 2010, 02:49 PM
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.
Tags
Ajax
Asked by
Graham
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Share this question
or