Creating TextBox dinamically

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.
 
M

Mark MacRae

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.
 
A

A

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top