RadAjax no longer allows more than one RadAjaxManager on the page. Instead, in a complex scenario like WebUserControls or Master/ContentPages, one should place RadAjaxManager instance on the main/master page and add a proxy control to the user control/content page.
RadAjaxManagerProxy copies the exact same RadAjaxManager designer configuration so that one can set all the necessary AJAX settings within the
WebUserControl/ContentPage entirely through the designer.
| ASP.NET |
Copy Code |
|
<telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="DropDownList1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="DetailsView1"
/>
<telerik:AjaxUpdatedControl ControlID="GridView1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="GridView1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="GridView1" />
<telerik:AjaxUpdatedControl ControlID="DetailsView1"
/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
|
The purpose of the new control is to ease the design-time configuration only. The Proxy does not provide client-side functionality as the Manager does. There is no
client-side object as well as functions like
ajaxRequest/ajaxRequestWithTarget and
client-side events. Instead, one can get the Manager instance through the
GetCurrent static method similar to the
ASP:ScriptManager control and call the master manager client-side methods if necessary.
| Accessing master manager client-side within WebUserControl/ContentPage |
Copy Code |
|
<telerik:RadCodeBlock
ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function myUserControlClickHandler()
{
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
}
</script>
</telerik:RadCodeBlock>
|
In case you need to handle the master manager events in the user control, you can attach event handlers to the manager as follows:
| Attaching server and client event handlers to master manager within WebUserControl/ContentPage |
Copy Code |
|
C#
protected void Page_Load(object sender, EventArgs e)
{
RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
manager.ClientEvents.OnRequestStart = "onRequestStart";
manager.ClientEvents.OnResponseEnd = "onResponseEnd";
manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);
}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim manager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)
manager.ClientEvents.OnRequestStart = "onRequestStart"
manager.ClientEvents.OnResponseEnd = "onResponseEnd"
AddHandler radAjaxManager.AjaxRequest, AddressOf radAjaxManager_AjaxRequest
End Sub
|
 |
When a server-side code block will be used one should wrap the entire script in a RadCodeBlock. |
 |
Should one need to add AJAX settings programmatically, it is
recommended to get the master manager instance and call its methods/properties as well. The same GetCurrent method could be used to access the
AJAX Manager placed in the Master/Main page from a Content page/WebUserControl. |