Creating TextBox dinamically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marco

    #1

    Creating TextBox dinamically

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


    Thanks.


  • Mark MacRae

    #2
    Re: Creating TextBox dinamically

    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" <marcod@zipmail .com.br> wrote in message
    news:OxOdErGTDH A.1552@TK2MSFTN GP12.phx.gbl...[color=blue]
    > How I can create TextBox dinamically.
    > I have to create 10 textbox dinamically which name will be txtBox_01,
    > txtBox_02, etc...
    >
    >
    > Thanks.
    >
    >[/color]


    Comment

    • A

      #3
      Re: Creating TextBox dinamically


      "Marco" <marcod@zipmail .com.br> wrote in message
      news:OxOdErGTDH A.1552@TK2MSFTN GP12.phx.gbl...[color=blue]
      > How I can create TextBox dinamically.
      > I have to create 10 textbox dinamically which name will be txtBox_01,
      > txtBox_02, etc...[/color]

      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.A dd( txt );
      }
      }

      -akshay


      Comment

      Working...