creat text box

Discussion in 'C#' started by devilonline, Sep 8, 2010.

  1. devilonline

    devilonline New Member

    Joined:
    Sep 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi, i have this code that every time i click the button it creates a text box, how can i do this more than one time? thanks

    Code:
            private void button1_Click(object sender, EventArgs e)
            {
                TextBox myText = new TextBox();
         
                myText.Text = "";
                this.Controls.Add(myText);
    
    
            }
     
  2. Ami Desai

    Ami Desai Member

    Joined:
    Jan 5, 2017
    Messages:
    42
    Likes Received:
    17
    Trophy Points:
    8
    Location:
    Ahmedabad
    Home Page:
    http://www.ifourtechnolab.com/
    Hi,

    You can check this
    Code:
    TextBox tb;
    static int i = 0;
    protected void addnewtext_Click(object sender, EventArgs e)
    {
            i++;
        for(j=0;j<=i;j++)
        {
        tb = new TextBox();
        tb.ID = j.ToString();
    
        PlaceHolder1.Controls.Add(tb);
        }
    
    }
    Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice