Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the ScriptManager of Master Page into Child page's code behind c# (.cs) file

Tags:

Following is the web site environment I created:

  1. I have a Master page.
  2. I have created a Child page from it.
  3. I have placed Script Manager on the Master page.

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.

like image 853
Imran Rizvi Avatar asked Dec 22 '11 09:12

Imran Rizvi


People also ask

How do I get the Master Page button on the content 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.

What is ScriptManager C#?

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.


2 Answers

I got it, its given in ScriptManager class itself.

System.Web.UI.ScriptManager.GetCurrent(this.Page);
like image 54
Imran Rizvi Avatar answered Sep 17 '22 03:09

Imran Rizvi


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
like image 32
Alok Avatar answered Sep 21 '22 03:09

Alok