As i come from a PHP background and am doing some ASP work i was wondering how ASP handles dynamic form elements and posting.
Are you able to add dynamic elements to a form via JS and then get ASP to extract that data when its posted to the server? In PHP this stuff is a bit of a pain but allows for some easy to use forms for users, but in ASP it seems a bit stricter when it comes to client side things, unless ASP has visibility of things it just seems to ignore them.
Just to give an example of what i mean:
Imagine having a form with a combo box with numbers from 1-10. When selected X new controls need to appear beneath the combo box for the user to fill in without being submitted to the server. Once filled in and the form is submitted ASP would be able to access the data from each of the dynamically created controls.
In PHP the above wasnt nice, but was easy enough to implement as you could just check for the existance of form elements if you knew they would have a given prefix or similar, then get the data out, but with ASP im not sure how you could go about doing something similar... any help / advice would be great!
I agree. You will have to create it using document.createElement() in javascript and add it to the form. Only thing I would like to add to this is if you want to find the post back value of the dynamically created element then you will have to use the Request.Form collection. That is, say you dynamically create a text box and give it a name of 'mytxt' and also an id of 'mytxt' using javascript and added it to the form. Once you post back you will have to use request.form("mytxt") to get at the value typed in the dynamically created text box. Just some additional information if you need it.
Bookmarks