create a textbox dynamically at runtime how visible that textbox

Last post 05-16-2008 1:14 AM by rajeshthangarasu. 8 replies.

Sort Posts:

  • create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 3:08 AM

    hi to all

    In my application i created a textbox dynamically at runtime how visible that textbox. please guide me.

     

    by

    devan.g

  • Re: create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 3:16 AM
    Answer
        TextBox1 = new TextBox();
        TextBox1.ID = "TextBox1";
        TextBox1.Style["Position"] = "Absolute";
        TextBox1.Style["Top"] = "25px";
        TextBox1.Style["Left"] = "100px";
        Form1.Controls.Add(TextBox1);

     
    Hope it helps.

    -Manas
  • Re: create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 3:18 AM

     specify the size for the text box , it will be visible

  • Re: create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 3:18 AM
    Answer
    • Loading...
    • dinesh_sp
    • Joined on 12-03-2007, 5:41 AM
    • Melbourne
    • Posts 404

    Hi Devang,

    dim tbox as new textbox

    tbox.text="abcd"
    page.form.controls.add(tbox)

    This would add texbox on run time on page. Also if you want textbox on specific place use placeholder or panel and code is very similar
    panel1.controls.add(tbox)

    Hope this helps.

     

  • Re: create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 3:19 AM
    • Loading...
    • c#shiv
    • Joined on 01-11-2007, 3:52 AM
    • Posts 100

    You need to add that control on page in panel or placeholer etc.  You can set its visibility by setting Visible property of TextBox to true/false.

     

    Here is an example for you. 

    1    	     TextBox tb = new TextBox();
    2            tb.Text = "Dynamically Created";
    3            PlaceHolder1.Controls.Add(tb);
    

      

     

    PlaceHolder1 has been set on Page. By default visibility of TextBox control is true here.
    Mark As Answer if this post is useful to you.
    Thanks.
  • Re: create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 3:20 AM

     specify the size for the text box , it will be visible

  • Re: create a textbox dynamically at runtime how visible that textbox

    05-14-2008, 4:06 AM
    • Loading...
    • h_7asoona
    • Joined on 08-25-2007, 6:27 AM
    • Cairo
    • Posts 4

    I think that Patricipant replay is very good  &  achive the goal....  only I wanna add acomment  if  you  want  to add the text  in a specific plac only choose your <td> you want to put your text on it  from the design .... right click on this TD & choose  Run as server control & it's by default have the ID (td1)....  so write in  code ....

    TextBox Newtext= new TextBox();

    Newtext.Text = "Hassan";

    Newtext.ID="textbox100";

    Newtext.Visible = true;

    Newtext.Style["Position"] = "Absolute";

    TD1.Controls.Add(Newtext);

  • Re: create a textbox dynamically at runtime how visible that textbox

    05-15-2008, 11:51 PM
    Answer

    Hi,

    I think you didn't add the TextBox into page: Page.Controls.Add(TextBox1);

    Hope it helps.

     

    Sincerely,
    Vince Xu
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: create a textbox dynamically at runtime how visible that textbox

    05-16-2008, 1:14 AM

     You have to place your dynamically created controls inside a panel or placeholder

    eg:

     
       	     TextBox tbox = new TextBox();
                 tbox.Text = "My Text Box";
                 PlaceHolder1.Controls.Add(tbox);
    
    
     

     

    Mark as Answer if the post was useful to you

    Rajesh Thangarasu
    Microsoft Certified Professional
Page 1 of 1 (9 items)