在母版页中创建特定于页面的子项
在我的母版页初始化子中,我有一个数据/文本块被写入控件。基本想法是它应该在每个页面上都可用(显然)。但是,我遇到了一种情况,我需要这种情况不要发生在某个页面上。除了为此特定页面制作新的母版页之外,我还能做些什么来使这项工作正常进行吗?如果需要的话,我还使用一个基本页面。谢谢!
in my master page init sub I have a block of data/text being written to a control. The basic idea was that it should be available on every page (obviously). However, I have come across a situation in which I need this to NOT happen on a certain page. Is there anything I can do, short of making a new master page for this specific page, to make this work? I also use a basepage, if that ever needs to come into play. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在基页类中创建一个名为
ShouldDoThingy
的虚拟只读属性,该属性始终返回 false。在此特定页面中覆盖它以返回 true。
在母版页中,检查
if (((BasePageClass)Page).ShouldDoThingy)
Make a virtual readonly property in your base page class called
ShouldDoThingy
that always returns false.Override it in this specific page to return true.
In the master page, check
if (((BasePageClass)Page).ShouldDoThingy)
如果只有一两页,并且您没有可以按照 SLaks 的建议使用的基页类,那么您始终可以只检查当前请求 url:
If it is only a page or two and you don't have a basepage class you can use as suggested by SLaks, you can always just check the current request url: