Following is the web site environment I created:
以下是我创建的网站环境:
- I have a Master page.
- 我有一个母版页面。
- I have created a Child page from it.
- 我已经从中创建了一个子页面。
- I have placed Script Manager on the Master page.
- 我已将Script Manager放在Master页面上。
Now I want to access that Master page's Script Manager to create a User Control dynamically in my code behind (C#) file.
现在我想访问Master页面的脚本管理器,在我的代码隐藏(C#)文件中动态创建用户控件。
How can I access Script Manager placed on master page to my child page.
如何访问母版页上的脚本管理器到我的子页面。
3 个解决方案
#1
51
I got it, its given in ScriptManager class itself.
我得到了它,它在ScriptManager类本身中给出。
System.Web.UI.ScriptManager.GetCurrent(this.Page);
#2
5
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
您可以通过后面的代码中的Page.Master访问母版页
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
#3
1
Have you checked out this:
你看过这个:
Working with ASP.NET Master Pages Programmatically
http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
以编程方式使用ASP.NET母版页http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
#1
51
I got it, its given in ScriptManager class itself.
我得到了它,它在ScriptManager类本身中给出。
System.Web.UI.ScriptManager.GetCurrent(this.Page);
#2
5
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
您可以通过后面的代码中的Page.Master访问母版页
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
#3
1
Have you checked out this:
你看过这个:
Working with ASP.NET Master Pages Programmatically
http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
以编程方式使用ASP.NET母版页http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx