Click here to Skip to main content
15,905,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,
i would like to create dynamically text box and a label on link button click, so that client will not be restricted for the limited option on label and text box.
client will able to add as much as new field on single click.
help!!
thanks.
Posted
Updated 14-Feb-12 18:59pm
v2
Comments
sawant parag 15-Feb-12 0:50am    
Dynamic creation of text box and label on button click ....

//create the object of the control you want for example
TextBox txt=new TextBox();
//set the properties of control for example
txt.Text="dfgdgf";
 
Share this answer
 
Comments
sawant parag 15-Feb-12 1:02am    
i want place the text box in the same table but into the different tr?
the table is inside the Tab Controller of Ajax tool kit.
mylogics 15-Feb-12 1:06am    
you have to generate the dynamic html code for the same or have to place the dynamic textbox in controls like griedview and repeater.
sawant parag 15-Feb-12 1:09am    
pls help how i have generate this dynamic html ?
mylogics 15-Feb-12 1:13am    
I dont know what is your requirement exactly let me know the deatils or Google it....!!
Offcourse you can do it in asp.net even in windows application..
Try this:

Label lblID=new Label();
lblID.Text="New Label";
TextBox txtID=new TextBox();
//add this controls to your form or panel(where ever you want)
form1.Controls.Add(lblID);
form1.Controls.Add(txtID);

Accept my answer, if you like it..

All the best.. :)
 
Share this answer
 
Comments
sawant parag 15-Feb-12 2:34am    
Actually I wanted the ID of the dynamically generated Text Boxes in the code behind, so I used the below code-

private void CreateLabel(string ID)
{
Label lbl = new Label();
lbl.ID = ID;
pnlTextBox.Controls.Add(lbl);
Literal lt = new Literal();
lt.Text = "Enter Node for InputXML:";
pnlTextBox.Controls.Add(lt);
}

private void CreateTextBox(string ID)
{
TextBox txt = new TextBox();
txt.ID = ID;
txt.AutoPostBack = true;
txt.TextChanged += new EventHandler(OnTextChanged);
pnlTextBox.Controls.Add(txt);
Literal lt = new Literal();
lt.Text = "<br />";
pnlTextBox.Controls.Add(lt);
}

The ID used is generated dynamically in below format -
lblDynamic-<count of="" number="" dynamic="" labels="" +="" 1=""> (e.g. lblDynamic-2 : if I've already generated one)
txtDynamic-<count of="" number="" dynamic="" text="" boxes="" +="" 1=""> (e.g. txtDynamic-2 : if I've already generated one)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900