Following is the web site environment I created:
Now I want to access that Master page's Script Manager to create a User Control dynamically in my code behind (C#) file.
How can I access Script Manager placed on master page to my child page.
To access the master page controls we need to use the Master key word then call the Property method of control. As we use Master. EnterNameTextBox() to access the master page EnterName textbox and Master. SendDataToContentPageButton() method is used to acees master page button.
ScriptManager is a server-side control that sits on your Web Form and enables the core of ASP.NET AJAX. Its primary role is the arbitration of all other ASP.NET AJAX controls on the Web Form and the addition of the right scripting libraries to the Web browser so that the client portion of ASP.NET AJAX can function.
I got it, its given in ScriptManager class itself.
System.Web.UI.ScriptManager.GetCurrent(this.Page);
Not sure what exactly you want here... you want to access the script manager of your master page or just the masterpage
?
You can access the master page by
Page.Master
in code behind
Or
using System.Web.UI;
ScriptManager ScriptManager1 = (ScriptManager)Page.Master.FindControl("ScriptManager1")
// to access the script manager of master page
or
Page.Master.Controls.Add(Your UserControl object)
// to add the user control in your master page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With