当我们将MasterPageFile设为空串后,在每次更新标准主页后在发布时都得手工来修改这个属性。如果不想这么麻烦的话,可以通过一些手段来欺骗一个Visual Studio .NET的设计视图。首先建立一个从System.Web.UI.Page继承的类(将这个类命名为BasePage)。在这个类中定义一个RuntimeMasterPageFile属性(这个属性可以使用任何名子)。实现代码如下:
以下是引用片段:
public class BasePage : System.Web.UI.Page {
private string _RuntimeMasterPageFile;
public string RuntimeMasterPageFile {
get {
return _RuntimeMasterPageFile;
}
set {
_RuntimeMasterPageFile = value;
}
}