[resolved] Script Manager in ASP.net master page issue
If you are using a script manager in your master page in order to share it with all your pages instead of adding a script manager to each page , you need to follow the following steps in order to avoid any further problems:
1- Make sure you have added the script manager tag after opening of Form tag.
2- To access the master page script manager you may use one of those ways :
- Create a public property in your master page which will return the current instance of script manager and use it in your content page.
In your master page .cs file
public ScriptManager rootScriptManager {
get { return matserScriptManager; }
}
In content page
//Sit1 is the master page class name Site1 site1 = Master as Site1; //check the script manager property if(site1.rootScriptManager.IsInAsyncPostBack) { //Do something }
- Finding the script manager using System.Web.UI.Page.FindControl
ScriptManager scriptManager =(ScriptManager)Master.FindControl("matserScriptManager");
if(scriptManager != null && scriptManager.IsInAsyncPostBack){//Do something
}if(scriptManager != null && scriptManager.IsInAsyncPostBack){//Do something
}
- Another way which is recommended
Hope it helps :)ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page); if(scriptManager != null && scriptManager.IsInAsyncPostBack) { //Do something }