【问题标题】:Is it possible to read the content of a content place holder from the masterpage?是否可以从母版页读取内容占位符的内容?
【发布时间】:2010-10-26 06:48:22
【问题描述】:

我们想在我们的页面中使用 contentPlaceHolder 来设置标题。我们想做的是让母版页检查 contentPlaceHolder 以查看其中是否有内容。通过这种方式,我们可以设置一个电子邮件程序,它会告诉我们哪些页面没有页面标题,因为我们有一个相当大的站点。我们也有嵌套的母版页。有没有人有好的方法来做到这一点?

【问题讨论】:

    标签: c# asp.net contentplaceholder


    【解决方案1】:

    我建议使用 pages 的 title 属性。然后您只需要检查属性以确定是否设置了标题。

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

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

    在我的母版页中,我有这个...

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

    您可以在母版页中的某处检查 string.IsNullOrEmpty(Page.Title),如果为真则发送电子邮件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-09
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多