Properties
The AjaxManager exposes a set of server-side properties.
The following list shows some of the most frequently used ones. For the full list, refer to the Server-Side API of the RadAjaxManager class.
-
EnableAJAX—When you set theEnableAJAXproperty totrue(the default), all requests (controls either within theRadAjaxPanelTemplate or managed by theRadAjaxManager) are handled with AJAX. If this property isfalse, requests are handled in the legacy postback manner. -
EnableHistory—When you set theEnableHistoryproperty totrue(the default isfalse), the browser history is enabled, even when using AJAX. The Forward and Back buttons of the browser work as expected (IE browser only). For more information, refer to the article on the Back and Forward browser buttons. -
EnablePageHeadUpdate—When you set theEnablePageHeadUpdateproperty totrue(the default), the Page<head>element can be modified during AJAX updates. You'll find this functionality especially useful when you initiate controls as invisible or when loading the control dynamically on an AJAX request. -
IsAjaxRequest—Set this property totruewhen the current request is through AJAX, and tofalsewhen the request is a standard postback. In the following example,Button1has been configured to be AJAX-enabled and the alert will displaytrue. ClickingButton2will displayfalse.The following example demonstrates how to set the
IsAjaxRequest.ASP.NET<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="Button1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="Label1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />C#protected void Button1_Click(object sender, EventArgs e) { RadAjaxManager1.Alert(RadAjaxManager1.IsAjaxRequest.ToString()); } protected void Button2_Click(object sender, EventArgs e) { RadAjaxManager1.Alert(RadAjaxManager1.IsAjaxRequest.ToString()); }VBProtected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) RadAjaxManager1.Alert(RadAjaxManager1.IsAjaxRequest.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) RadAjaxManager1.Alert(RadAjaxManager1.IsAjaxRequest.ToString()) End Sub -
DefaultLoadingPanelID—Allows you to specify a defaultLoadingPanelthat will be shown when updating AJAX-enabled controls. -
UpdatePanelsRenderMode—Determines the way of rendering the AJAX panels. When you chose theBlockoption, the panels will be rendered asdivelements. If you chose theInlineoption, the panels will be rendered asspanelements. -
UpdateInitiatorPanelsOnly—By setting this property totrue(its default value isfalse), only the containers added asUpdatedControlsfor a specific initiator will be conditionally updated. For more information, refer to the article on updating the UpdatePanels of the initiator only. -
ResponseScripts—This collection of strings contains JavaScript for you to execute when the response returns to the browser. In the following example, analert()JavaScript function is added to the collection. Also, see below for the rendered HTML results showing the call toalert()near the end of the HTML.C#protected void Button2_Click(object sender, EventArgs e) { RadAjaxManager1.ResponseScripts.Add("alert('this fires after the response');"); }VBProtected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) RadAjaxManager1.ResponseScripts.Add("alert('this fires after the response');") End SubThe following example contains some sample code showing the usage of the
ResponseScriptsproperty.JavaScript<script type="text/javascript"> setTimeout(function () { alert('this fires after the response'); }, 0); Sys.Application.initialize(); Sys.Application.add_init(function () { $create(Telerik.Web.UI.RadAjaxManager, { "ajaxSettings": [{ InitControlID: "Button1", UpdatedControls: [{ ControlID: "Label1", PanelID: ""}]}], "clientEvents": { OnRequestStart: "", OnResponseEnd: "" },"defaultLoadingPanelID": "", "enableAJAX": true, "enableHistory": false, "links": [], "styles": [], "uniqueID": "RadAjaxManager1" }, null, null, $get("RadAjaxManager1")); }); </script>