我该怎么做才能避免页面在运行时有条件地继承主页? [英] What can I do to avoid a page from inheriting the master page conditionally at run time?

查看:47
本文介绍了我该怎么做才能避免页面在运行时有条件地继承主页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止内容页面在运行时有条件地继承母版页?

How can I prevent a Content Page from inheriting the Master Page conditionally at run-time?

推荐答案

您可以将母版页动态附加到内容页面。由于在页面处理的初始化阶段合并主页面和内容页面,因此必须先分配主页面。通常,您在PreInit阶段动态分配母版页。

You can attach a master page dynamically to a content page. Because the master page and content page are merged during the initialization stage of page processing, a master page must be assigned before then. Typically, you assign a master page dynamically during the PreInit stage.
void Page_PreInit(Object sender, EventArgs e)
{
    this.MasterPageFile = "~/MyMaster.master";
}



请注意MSDN上的这篇文章:



http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx



谢谢,

-RG


Please note this article on MSDN:

http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx

Thanks,
-RG


这篇关于我该怎么做才能避免页面在运行时有条件地继承主页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆