Creating TextBox dinamically

  • Thread starter Thread starter Marco
  • Start date Start date
M

Marco

How I can create TextBox dinamically.
I have to create 10 textbox dinamically which name will be txtBox_01,
txtBox_02, etc...


Thanks.
 
The way I do it is to dynamically write a bunch of HTML to a string, then
set the Text value of a label on the page to be that string. It's simple
but effective.
 
Marco said:
How I can create TextBox dinamically.
I have to create 10 textbox dinamically which name will be txtBox_01,
txtBox_02, etc...

You can do something like this:

public void AddTextBoxes( int number ){
for( int i = 0; i < number; i++ ){
string name = "txtBox_" + ( i + 1 ).ToString( "00" );
TextBox txt = new TextBox();
txt.Name = name;
// Set other properties such as size and location and TabIndex if
you wish.
this.Controls.Add( txt );
}
}

-akshay
 
Back
Top