How to get text from dyanmically created texboxes
-
HI, I have an ASP form, and I want to make it so that if you click on an "Add Follow-Up" button, a text box gets added to a table. I then want what ever the user puts in that text box to be saved when the submit button is pressed. My problem is that while I can create that text button the first time the Add Follow-up button is pressed, I can't save it to the database. When stepping through the code, it looks like there's nothing in the placeholder controls. (The followup textbox is added to a placeholder so I can get it to go where I want it to.) Is there any way to save this information to the database when pressing the Submit button? Thanks, Muntyness
-
HI, I have an ASP form, and I want to make it so that if you click on an "Add Follow-Up" button, a text box gets added to a table. I then want what ever the user puts in that text box to be saved when the submit button is pressed. My problem is that while I can create that text button the first time the Add Follow-up button is pressed, I can't save it to the database. When stepping through the code, it looks like there's nothing in the placeholder controls. (The followup textbox is added to a placeholder so I can get it to go where I want it to.) Is there any way to save this information to the database when pressing the Submit button? Thanks, Muntyness
Did you check the contents of
Request.Form[""]
orRequest.Params[""]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
HI, I have an ASP form, and I want to make it so that if you click on an "Add Follow-Up" button, a text box gets added to a table. I then want what ever the user puts in that text box to be saved when the submit button is pressed. My problem is that while I can create that text button the first time the Add Follow-up button is pressed, I can't save it to the database. When stepping through the code, it looks like there's nothing in the placeholder controls. (The followup textbox is added to a placeholder so I can get it to go where I want it to.) Is there any way to save this information to the database when pressing the Submit button? Thanks, Muntyness
To understand the problem clearly, you need to look through ASP.NET page life cycle. ViewState is stored and loaded in Init event. So all dynamic controls created after Init event won't maintain any viewstate. This is what you are not getting the control on postback. You need to find some other alternative like creating control on Init event.
-
Did you check the contents of
Request.Form[""]
orRequest.Params[""]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
Well I have now. *cough* Thanks. Can you think of any way of doing this for multiple new follow-ups? (I can think of a way of doing it with multiple old follow-ups, mainly by using whatever ID they have in the database as the ID for the textbox, and then when submitting the form, getting all of the IDs from an array, then looping through the array to get the information for the old followups from the text boxes and updating the database if needed. Of course if you know of a better way, I'd be happy to use it.) For new followups, I can only think of how to add 1 at a time, and I would prefer to be able to add multiple new ones if possible. (And I can't submit them to the database when adding new followups, as I need a ID which won't be generated until the entire form is submitted.) Thanks, Muntyness