New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Callback Configuration
This article explains how to configure the RadXmlHttpPanel's callback:
-
Add RadXmlHttpPanel ASP.NET AJAX to the page.
-
Set the EnableClientScriptEvaluation property to true to enable the evaluation of scripts loaded by the controls within the XmlHttpPanel.
-
Place a Label control inside the RadXmlHttpPanel.
-
Handle the ServiceRequest server-side event of RadXmlHttpPanel.
-
In the handler method, add the following code:
C#protected void RadXmlHttpPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e) { Label1.Text = "Label updated by XmlHttpPanel callback at: " + DateTime.Now.ToString(); }
VBProtected Sub RadXmlHttpPanel1_ServiceRequest(sender As Object, e As Telerik.Web.UI.RadXmlHttpPanelEventArgs) Label1.Text = "Label updated by XmlHttpPanel callback at: " + Now.ToString() End Sub
-
Create an
<input/>
of type button that will call the set_value client method of the XmlHttpPanel, on a button click. You can also access the callback value from the client on the server using thee.Value
property in the ServiceRequest event. Here is how the page and its code-behind should look after completing the steps above:ASP.NET<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadXmlHttpPanel runat="server" ID="RadXmlHttpPanel1" EnableClientScriptEvaluation="true" OnServiceRequest="RadXmlHttpPanel1_ServiceRequest"> <asp:Label ID="Label2" runat="server"></asp:Label> </telerik:RadXmlHttpPanel> <br /> <br /> <br /> <input type="button" value="Set Value" onclick="SetValue();return false;" /> <script type="text/javascript"> function SetValue() { var panel = $find("<%=RadXmlHttpPanel1.ClientID %>"); panel.set_value("string_value"); } </script>
C#protected void RadXmlHttpPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e) { Label1.Text = "Label updated by XmlHttpPanel callback at: " + DateTime.Now.ToString(); //access the callback value from the client on the server using the e.Value property Label1.Text += "<br/> The returned value fron the client's set_value() function is: <strong>" + e.Value + "</strong>"; }
VBProtected Sub RadXmlHttpPanel1_ServiceRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadXmlHttpPanelEventArgs) Label1.Text = "Label updated by XmlHttpPanel callback at: " + DateTime.Now.ToString() 'access the callback value from the client on the server using the e.Value property Label1.Text += "<br/> The returned value fron the client's set_value() function is: <strong>" + e.Value + "</strong>" End Sub