首页 > 代码库 > 动态创建asp.net控件

动态创建asp.net控件

    int i=0;
            try
            {
                i = Int16.Parse(txt_num.Text);
            }

            catch { }

            TextBox _txt;//创建text 对象
            if (i > 0)
            {
                for (int _i = 0; _i < i; _i++)
                {
                    _txt = new TextBox(); //实例化Text对象
                    _txt.Text = _i.ToString();//实例化Text对象名称
                    Panel1.Controls.Add(_txt);//panel中创建Text控件

                }
            }