Identifying dynamic controls
-
Hi All, I create 2 controls dynamically - one textbox and one "Add" button.These controls are present in 2 different groups.If I click the button it should add a textbox to the textbox group. I need to create the textboxes based on the button click. Any help would be appreciated.
vijaya
-
Hi All, I create 2 controls dynamically - one textbox and one "Add" button.These controls are present in 2 different groups.If I click the button it should add a textbox to the textbox group. I need to create the textboxes based on the button click. Any help would be appreciated.
vijaya
When you dynamically add the "Add" button, you can also add the event handler for the Click event to add the textbox at runtime. And you need to be careful when working with the dynamic controls as there two common mistakes that you may see: the dynamic controls get lost and the postback events do not execute. How to: Add Controls to an ASP.NET Web Page Programmatically [^]
-
When you dynamically add the "Add" button, you can also add the event handler for the Click event to add the textbox at runtime. And you need to be careful when working with the dynamic controls as there two common mistakes that you may see: the dynamic controls get lost and the postback events do not execute. How to: Add Controls to an ASP.NET Web Page Programmatically [^]
Hi Thanks for Reply. Actually my problem is Iam building two groups A and B.Each group contains one textbox and add button(all are builded dynamically).If i click on add button it should add textboxes to respective group.For add button click iam adding attributes and incrementing value from javascript using a hidden variable. btnAddRange.Attributes.Add("onclick","javascript:submitVIN('"+GroupId+"')") this is code for click on a button.How can we identify click is performed on respective group. Regards, Vijaya
vijaya
-
Hi Thanks for Reply. Actually my problem is Iam building two groups A and B.Each group contains one textbox and add button(all are builded dynamically).If i click on add button it should add textboxes to respective group.For add button click iam adding attributes and incrementing value from javascript using a hidden variable. btnAddRange.Attributes.Add("onclick","javascript:submitVIN('"+GroupId+"')") this is code for click on a button.How can we identify click is performed on respective group. Regards, Vijaya
vijaya
-
Do you mean you want to determine which button is firing the event? and you might want to do that at the client side or the server side?
Hi, Thanks for your reply. Sorry for delay in reply. My Problem was solved. I have one more Problem regarding this dynamic creation of controls. Delete option is there to delete respective row which is added by click on the add button.Iam using Request.form to read the values and save in to database.After clicking delete button ,Iam deleting that row value from database but page was loading values using request.form(control) but i need controls should load values from database. Pls Help me,My project was in delivery stage pls reply me as soon as possible.And Thanks for help. Thanks & Regards, Vijaya.K
vijaya
-
Hi, Thanks for your reply. Sorry for delay in reply. My Problem was solved. I have one more Problem regarding this dynamic creation of controls. Delete option is there to delete respective row which is added by click on the add button.Iam using Request.form to read the values and save in to database.After clicking delete button ,Iam deleting that row value from database but page was loading values using request.form(control) but i need controls should load values from database. Pls Help me,My project was in delivery stage pls reply me as soon as possible.And Thanks for help. Thanks & Regards, Vijaya.K
vijaya
Not sure about what your code is doing, but IMO you can simply refresh the control with the data in DB after you delete the row. In other words, you can have put your code somewhere else to set the control value, and this basically happens after the row is deleted.