在构造Web窗体? [英] Constructor in webform?

查看:119
本文介绍了在构造Web窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET表单在我的页面这样

I have an ASP.NET webform where I initialize an array with a list of controls on the page like this

FileUpload[4] = new FileUpload[4];
public myclass()
{
 fileUpload[0] = FileUpload1;
 fileUpload[0] = FileUpload2;
...etc
}

我然后在页面加载使用这些,他们都是空。这似乎是一个奇怪的行为给我。有人能详细解释?我可以理解,他们是在构造空,但为什么要在页面加载使用时为空。

I then use these in the page load and they are all null. This seems a strange behavior to me. Can someone elaborate and explain? I can understand that they are null in the constructor but why should they be null when used in the page load.

推荐答案

他们都为空,因为控制已尚未创建。

They are null because the controls haven't been created yet.

看看在 ASP.NET页生命周期概述和Init事件。

Take a look at the ASP.NET Page Life Cycle Overview and the Init event.

这篇关于在构造Web窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆