Search code examples
asp.netcode-behinddynamically-generatedhtml-input

How to retrieve values of dynamically created controls in code behind?


I intend to use Javascript to dynamically create a group of html elements (input boxes, select list, radio button, etc.) each time the user clicks "Add More" button.

I have found the Javascript that does that here:

So how do I get the values of these dynamically created HTML elements from code-behind? Is there a JQuery way which is better?

Thank you.


Solution

  • I think you'd may be able to do it with a callback/async postback to your ASP.NET page to update the control tree as you update. Not sure how the ViewState is updated/affected by this.

    Otherwise, because your messing with the ViewState, so you'll need to revert to accessing them by the Request.Form object.