0
我想覆盖我的类_Default
中的Page_PreInit
函数,它继承自Page
。然而,当我尝试编译我收到以下错误:覆盖时编译错误Page_PreInit
'_Default.Page_PreInit(object, System.EventArgs)': no suitable method found to override
这里是我的代码:
public partial class _Default : Page
{
protected override void Page_PreInit(object sender, EventArgs e)
{
// Todo:
// The _Default class overrides the Page_PreInit method and sets the value
// of the MasterPageFile property to the current value in the
// selectedLayout session variable.
MasterPageFile = Master.Session["selectedLayout"];
}
...
}
哦,好吧,这很有道理,谢谢! 仍存在错误“未将对象引用设置为对象的实例”。 here: MasterPageFile = Master.Session [“selectedLayout”]; – shenn
尝试'this.Session'而不是'Master.Session'。 –
this.session带有:不能将[]应用于表达式类型'method group' – shenn