测试 ContentPlaceHolder 内容是否已被子页面覆盖?
我目前正在将 .net 1.1 应用程序迁移到 .net 3.5。
.net 1.1 应用程序有许多页面+用户控件,我希望将其迁移到母版页。
我的问题是尝试以编程方式进行测试,以查看母版页的 contentplaceholders 内容是否已被子页面覆盖。
- 是否可以?
- 有人有样品或参考资料可供我看一下吗?
提前致谢。
I'm currently migrating a .net 1.1 application to .net 3.5.
The .net 1.1 application has a number of number of page + usercontrol's that I would like migrated to masterpages.
My issue is trying to test progmatically to see if the masterpage's contentplaceholders content has been overridden by a child page.
- Is it possible?
- Does anyone have samples or references that I could take a look at?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
页面可以与母版页通信,但反之则不然,因为 contentplaceholder 中的内容不属于母版页。 设置页面将自身“注册”到母版页的最快方法是声明一个继承自 .NET MasterPage 的类,并公开该类中的通信功能。
公共抽象类 MyMaster :System.Web.UI.MasterPage
{
public MyMaster() { }
}
然后,在使用母版页的页面中,您可以执行以下操作:
当然,假设您有一个 SomeArgs 类,其中包含您希望母版页了解的数据。
A page can communicate with the master page but not vice versa since the content in the contentplaceholder does not belong to the master page. The quickest way of setting up a page "registering" itself to the master page is to declare a class that inherits from the .NET MasterPage and expose communication functionality in that class.
public abstract class MyMaster : System.Web.UI.MasterPage
{
public MyMaster() { }
}
Then in your page that uses the master you can do something like:
Assuming of course that you have a SomeArgs class that contains the data you want the master page to know about.