简体   繁体   English

如何将Master Page的ScriptManager放入c#(.cs)文件后面的Child页面代码中

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

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. 我已将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. 如何访问放置在母版页上的脚本管理器到我的子页面。

我得到了它,它在ScriptManager类本身中给出。

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 ? 不知道你想在这里什么......你要访问您的母版页的脚本管理器或只是masterpage

You can access the master page by Page.Master in code behind 您可以通过Page.Master的代码中的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

Have you checked out this: 你看过这个:

Working with ASP.NET Master Pages Programmatically 以编程方式使用ASP.NET母版页
http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在“母版详细信息页面”中加载视图并激活其子类C#代码? - How to load a view in Master Detail Page, and activate it's child class C# code? 在母版页代码中获取页面标题 - Get Page Title In Master Page Code Behind 将代码从我的.aspx页面转换为C#.cs页面中的代码 - Converting code from my .aspx page to code behind in the C# .cs page 在嵌套母版页中,子母版页代码后面的代码无法正常工作 - In nested master pages child master page code behind not working properly C#-我无法从背后的代码访问母版页的img标签的src属性 - C# - I can't access my Master Page's img tag's src attribute from my code behind 主页面和内容页面中的ScriptManager - ScriptManager in Master page and Content page 在Html页面(内联)和aspx.cs(后面的代码)中编写C#代码之间的区别 - Difference between writing C# code in Html page(inline) and aspx.cs (code behind) 如何通过C#从SharePoint页面删除ScriptManager - How to remove ScriptManager from SharePoint Page via C# 从后面的子母版页代码访问子母版页上的用户控件 - Accessing user control on child master page from child master page code behind 如何在母版页后面的代码中访问Telerik RadEditor控件(嵌入在“内容”页中)? - How do you access Telerik RadEditor control (embedded in Content page) in master page's code behind?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM