Sub: Extensive use of ScriptManager control
There are many interesting scenarios where your expectations will fail when we AJAXify our pages, leaving you with a mess on your hands. In this post, we’ll see extensive use of: the ScriptManager control.
In days of old you would have added script to the page as a result of a full postback such as this:
But this new method can break under ASP.NET AJAX. Why? Because ClientScriptManager is not a control that understands partial postbacks and partial rendering, and so script code registered with it will not be included in the page response for a partial postback.
Instead, if you wanted the button to introduce client script into the page output, you would leverage the ScriptManager:
The result is the same, but the method is slightly different. In fact, the methods of the ClientScriptManager control are now included in the ScriptManager control as static methods (RegisterStartupScript, for example). Whenever you are utilizing ASP.NET AJAX and want to work with script through partial postbacks, you must now use methods exposed by the ScriptManager control instead.
RegisterAsyncPostBackControl - Programmatically adding Triggers
When a button is not present in Update Panel, you can programmatically identify triggers and cause an UpdatePanel control to refresh in the server code of your page.
RegisterPostBackControl- Forcing Full
You could also make an element inside an UpdatePanel cause the whole page to refresh—a full postback. To do so, you just use a different method on the ScriptManager called RegisterPostBackControl.
RegisterDataItem: Refresh controls or data outside an UpdatePanel
ScriptManager's RegisterDataItem method makes it easy to refresh controls or data outside an UpdatePanel. RegisterDataItem allows extra data of your choosing to be sent down to the client when an UpdatePanel control posts back; the data can be consumed by script you write on the client.
In this example, I want to update the Textbox with whatever value has been clicked in the Calendar control.
Along with the above code, below JS code is also required.
var prm = Sys.WebForms.PageRequestManager.getInstance();
var dataItems = args.get_dataItems();
$get('TextBox1').value = dataItems['TextBox1'];
function EndRequest(sender, args)
if(typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
Note: Copy-Paste of code may not work properly. Please do consider them just as a close reference to your need. In case of any doubts feel free to call me.