是否可以从母版页读取内容占位符的内容?
我们想在页面中使用 contentPlaceHolder 来设置标题。我们想要做的是让母版页检查 contentPlaceHolder 以查看其中是否有内容。这样我们就可以设置一个电子邮件程序,它会告诉我们哪些页面没有页面标题,因为我们有一个相当大的网站。我们还有嵌套的母版页。有没有人有一个好方法来做到这一点?
We would like to use a contentPlaceHolder in our pages to set titles. What we would like to do is have the masterpage check the contentPlaceHolder to see if it has content in it. This way we can set up an e-mailer that will tell us what pages that don't have page titles since we have a fairly large site. We also have nested masterpages. Does anyone have a good way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用页面标题属性。然后您只需要检查属性即可确定是否设置了标题。
在我看来,我有这个...
并且在我的母版页中我有这个...
您可以在母版页中的某处检查 string.IsNullOrEmpty(Page.Title) 并发送电子邮件(如果为真)。
I would recommend using the pages title property. Then you would just need to check the property to determine if a title is set or not.
In my view I have this...
And in my master page I have this...
You can just check for string.IsNullOrEmpty(Page.Title) somewhere in your master page and send an email if true.