gpt4 book ai didi

c# - asp.net 覆盖

转载 作者:太空宇宙 更新时间:2023-11-03 11:31:02 24 4
gpt4 key购买 nike

使用标准事件处理程序或覆盖 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com