是否可以从母版页读取内容占位符的内容?

发布于 2024-09-28 20:22:03 字数 163 浏览 0 评论 0原文

我们想在页面中使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏璃陌 2024-10-05 20:22:03

我建议使用页面标题属性。然后您只需要检查属性即可确定是否设置了标题。

在我看来,我有这个...

<%@ Page Language="C#" Title="Hello World" ... %>

并且在我的母版页中我有这个...

<title><%=Page.Title%></title>

您可以在母版页中的某处检查 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...

<%@ Page Language="C#" Title="Hello World" ... %>

And in my master page I have this...

<title><%=Page.Title%></title>

You can just check for string.IsNullOrEmpty(Page.Title) somewhere in your master page and send an email if true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文