Get the ScriptManager Object in MasterPage from ContentPage in ASP.Net AJAX
If we develop ASP.Net AJAX application, we will have the ScriptManager object in the MasterPage instead of every content page. Sometimes, we will get a scenario where we want to access the ScriptManager object from Content page, For example: to add a control that is present external to an UpdatePanel as an asynchronous control.
ASP.Net AJAX provides the access to current ScriptManager object of the page through GetCurrent() method that is packed with ScriptManager object.
The below code snippet will help us to access the ScriptManager in Master page from content page to add a page control as an asynchronous control. Here, we are adding the button control btnSubmit as an Asynchronous control.
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager _scriptMan = ScriptManager.GetCurrent(this);
_scriptMan.RegisterAsyncPostBackControl(this.btnSubmit);
}
|