New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Ajaxifying Multi-Page Projects with the AjaxManagerProxy

The Ajaxifying Telerik mechanism allows you to use only a single AjaxManager on a page.

To work around this functionality and handle complex scenarios, for example, when using WebUserControls or Master/Content Pages, place a RadAjaxManager instance on the main or master page, and then add a RadAjaxManagerProxy control to the user control or content page.

The RadAjaxManagerProxy copies the exact same AjaxManager designer configuration so that you can set all the necessary AJAX settings within the WebUserControl or ContentPage entirely through the designer.

The following example shows how to use the RadAjaxManagerProxy to Ajax-enable controls within a WebUserControl or ContentPage.

ASP.NET
<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>

Using the RadAjaxManagerProxy makes the design-time configuration easier:

  • RadAjaxManagerProxy is an extension of the AjaxManager. To work work with it on client, use the AjaxManager Client-side APIs

  • You can get the RadAjaxManager instance through the GetCurrent static method similar to the asp:ScriptManager control and call the master RadAjaxManager client-side methods if necessary.

The following example demonstrates how to set the RadAjaxManager instance and fire an AJAX request.

When you use a server-side code block, wrap the entire script in a RadCodeBlock to prevent the System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) server error.

JavaScript
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
	<script type="text/javascript">
	    function myUserControlClickHandler() {
	        find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
	    }
	</script>
 </telerik:RadCodeBlock>

If you need to handle the master manager events in the user control or content page, attach event handlers to the RadAjaxManager as shown in the following example.

  • To add AJAX settings programmatically, it is recommended that you get the master RadAjaxManager instance and call its methods or properties as well.
  • You can use the same GetCurrent method to access the RadAjaxManager placed in the Master or Main page from a Content page or WebUserControl.
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);
}

protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
	//handle the manager AjaxRequest event here
}	

See Also

In this article
See Also
Not finding the help you need?
Contact Support