日期:2014-05-17  浏览次数:20556 次

Page_Load加载顺序
本帖最后由 u011343317 于 2013-08-07 12:56:12 编辑

  protected void Page_Load(object sender, EventArgs e)
    {
        SetEmpty();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    }
    private void SetEmpty()
    {
        foreach (Control c in this.Controls)
        {
            if (c is TextBox)
            {
               (c as TextBox).Text="";
            }
        }
    }


Page_Load加载时Controls没有TextBox。form1以下的都没
C#?加载顺序

------解决方案--------------------
this.Controls
=>
this.Form.Controls
------解决方案--------------------

------解决方案--------------------
你 TextBox 嵌套在哪个部位?

------解决方案--------------------
this.Controls
=>this.Page.Controls

你直接把控件ID写进去操作看有没有?
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Text = "你懂的";
        int count = this.Page.Controls.Count;
    }


------解决方案--------------------
应该有有的才对!你用楼上的方法试试,你这个button是否真实存在