gpt4 book ai didi

c# - C# 中的 Page_Load

转载 作者:太空狗 更新时间:2023-10-29 17:40:22 27 4
gpt4 key购买 nike

我正在使用 C# 网络应用程序。我想深入了解页面事件。因为我认为页面加载事件首先发生(当在浏览器中请求页面时)。但是当我尝试注释方法 protected void Page_Load(object sender, EventArgs e) 时,页面加载时没有错误。

最佳答案

即使没有 Page_Load() 方法,您的网页也可以正常工作。在调用 PreInit、Init() 等 Page_Load() 事件之前。引用页面生命周期。

Page_Load() 方法在 preLoad 事件之后被调用。使用 Page_Load() 您可以设置默认值或检查 postBacks 等。

 protected void Page_Load(object sender, EventArgs e)
{
int x = 10;
}

写这个并在 int x = 10 上设置一个断点;观看发件人和e。

关于c# - C# 中的 Page_Load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16294413/

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