ª
ªL©ú©v
Dear all:
Can I use the following code to generate controls dynamically? But put
it in a form having attribute "runat=server"??
If I use the code below, it will cause some error because of myBtn
doesn't have "runat=server".
System.Web.UI.WebControls.Button myBtn = new Button();
myBtn.ID = "dynaBtn";
myBtn.Text = "dynaBtn";
myBtn.Click += new System.EventHandler(this.ClickEventHandler);
this.Controls.Add(myBtn);
If this code can work exactly, how to specify "runat=server" to myBtn?
All code above is written by C# and in code-behind.
Thanks.
Andrew Feb 17,2004
Can I use the following code to generate controls dynamically? But put
it in a form having attribute "runat=server"??
If I use the code below, it will cause some error because of myBtn
doesn't have "runat=server".
System.Web.UI.WebControls.Button myBtn = new Button();
myBtn.ID = "dynaBtn";
myBtn.Text = "dynaBtn";
myBtn.Click += new System.EventHandler(this.ClickEventHandler);
this.Controls.Add(myBtn);
If this code can work exactly, how to specify "runat=server" to myBtn?
All code above is written by C# and in code-behind.
Thanks.
Andrew Feb 17,2004