Click here to Skip to main content
15,882,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I am working on project. I need to create textbox dynamically on clicking the Add button. And how to handle events of dynamically created textbox.

If any question, if you did not get my point clear than please ask. Its urgent. Please Help!!!

Please give me suggestion and help me to work on these.

It would be pleased and appreciated to any help

Thanks in advance..
Priya Sarin 14-Jun-12 1:55am    
Thank you sir for your reply... Its still not working...

Share this answer
Priya Sarin 13-Jun-12 8:47am    
Thank you so much sir, for your help.

I had almost go through these both link.
Sir, I am working on desktop application. Sorry I had not describe that in my post.

Sir in the first link of ASP Snippet.. There is a function of FindOccurence. I am not getting how these two line works and how to convert that in window form code.

string reqstr = Request.Form.ToString();

return ((reqstr.Length - reqstr.Replace(substr, "").Length)

/ substr.Length);

Please sir... Help me to work on these.
Thanks in advance..
Prasad_Kulkarni 13-Jun-12 9:15am    
These lines simply checks the occurrence of control in respective function.
protected void btnAdd_Click(object sender, EventArgs e)

//int cnt = FindOccurence("txtDynamic");

//CreateTextBox("txtDynamic-" + Convert.ToString(cnt + 1));

Label lblmilestone = new Label();
lblmilestone.Name = "lblmilest" + c;
lblmilestone.Text = "Milestone" + c;
lblmilestone.Location = new System.Drawing.Point(20, 18 + (20 * c));
lblmilestone.Size = new System.Drawing.Size(100, 22);

TextBox txtRun = new TextBox();
txtRun.Name = "txtDynamic" + c;
txtRun.Location = new System.Drawing.Point(129, 15 + (20 * c));
txtRun.Size = new System.Drawing.Size(200, 25);

TextBox txtRun1 = new TextBox();
txtRun1.Name = "txtDynamicx" + c++;
txtRun1.Location = new System.Drawing.Point(373, -5 + (20 * c));
txtRun1.Size = new System.Drawing.Size(100, 25);

Share this answer

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