从内容页访问母版页和嵌套母版页属性

发布于 2024-12-08 20:48:44 字数 136 浏览 0 评论 0原文

如何从内容页访问母版页属性和嵌套母版页属性?我目前在内容页中使用 <%@ MasterType 来访问嵌套母版页的属性,但我认为我不能简单地指定另一个母版类型来访问母版页。或者,我可以吗? (IIS6、.Net4、c#)。

谢谢, 乔恩

How do I access master page properties and a nested master page properties from a content page? I currently use <%@ MasterType in my content page to access properties of the nested master page, but I don't think I can simply specify another mastertype to get to the master page. Or, can I? (IIS6, .Net4, c#).

Thanks,
Jon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

爱的十字路口 2024-12-15 20:48:44

您可以通过 Page.Master< 访问母版页/a> 属性

重要: (MSDN)

  1. Master 属性返回与此关联的 MasterPage 对象
    页。该属性是只读的;但是,您可以设置属性
    它返回的 MasterPage 对象。

  2. Master 属性仅在引用母版的页面上有效
    MasterPageFile 属性中的页面。如果您访问主属性
    在未引用母版页的页面上,返回 null。这
    母版页的内容在 PreInit 之后才可用
    事件已引发。

You can access a master page by Page.Master property

Important: (MSDN)

  1. The Master property returns the MasterPage object associated with this
    page. This property is read-only; however, you can set properties on
    the MasterPage object it returns.

  2. The Master property is valid only on pages that reference a master
    page in the MasterPageFile property. If you access the Master property
    on a page that does not reference a master page, null is returned. The
    contents of a master page are not available until after the PreInit
    event has been raised.

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