Friday, June 20, 2008

Accessing ScriptManager

Apparently we can have only one script manager in a page so the normal practice is to add it in a Master page to be accessed by all pages. Sometimes you need to access the script manager in the code for example to register a button for an asynchronous call etc. It could be easily done by using the following method.

ScriptManager.GetCurrent(this.Page);


An example to register a control for an asynchronous call from a user control.

ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(btnUpdate);

No comments: