Executing Custom Javascript Code after AJAX Update
Telerik RadAjax offers the ability to execute custom JavaScript code that comes as a response from the server thus giving you more flexibility to complete more specific or complex tasks on the client. This help article shows a few ways to execute custom JavaScript code after an AJAX update.
The best and most intuitive approach is to use the ResponseScripts property of the RadAjaxPanel or RadAjaxManager .
Example 1 shows how to pop an alert when a Button is clicked.
protected void Button1_Click(object sender, System.EventArgs e)
{
RadAjaxPanel1.ResponseScripts.Add(string.Format("alert('Hello from the server! Server time is {0}');", DateTime.Now.ToLongTimeString()));
}
Example 2 shows another approach. You can use the RegisterStartupScript static method of the ScriptManager class:
protected void Button1_Click(object sender, EventArgs e)
{
string script = string.Format("alert('Hello from the server! Server time is {0}');", DateTime.Now.ToLongTimeString());
ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript", script, true);
}
You can also use the [pageLoaded] (https://msdn.microsoft.com/en-us/library/bb397523.aspx)event of the [PageRequestManager] (https://msdn.microsoft.com/en-us/library/bb311028.aspx) class.