RadControls for ASP.NET AJAX 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.
CopyASPX
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" 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.
CopyASPX
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function myUserControlClickHandler() {
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
}
</script>
</telerik:RadCodeBlock> Caution |
|---|
When a server-side code block will be used one should wrap the entire script in a RadCodeBlock.
|
In case you need to handle the master manager events in the user control or content page, you can attach event handlers to the manager as follows:
CopyC#
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);
}
protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
}
CopyVB
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 manager.AjaxRequest, AddressOf manager_AjaxRequest
End Sub
Protected Sub manager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
End Sub Note |
|---|
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.
|