使用标准事件处理程序或覆盖 asp.net 页面的基类的优缺点是什么?有没有?我见过两者都曾经做过同样的事情。
protected void Page_PreInit(object sender, EventArgs e)
{
//Put your code here
}
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
//Put your code here
}
最佳答案
如果您使用覆盖,您可以决定何时执行自定义函数。在基本方法之后或之前。但如果您使用自动接线事件,它将在基本事件之后执行。
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
//Put your code here
}
或
protected override void OnPreInit(EventArgs e)
{
//Put your code here
base.OnPreInit(e);
}
关于c# - asp.net 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7776591/