问题
My webpage generates a lot of HTML dynamically using jQuery to display data. However, I need to access those dynamic HTML controls from C#. I cannot do runat="server", because JQUERY does its magic at runtime, depending on what user selects.
Is there any way to access the HTML of these dynamically created controls from code behind?
Thanks!
回答1:
If all you need are values from input fields (input, select, radio, checkbox), just make sure JQuery creates those inside the main <form> tag, then you can read them in the server side, after the form is submitted, using Request.Form["myFieldName"].
来源:https://stackoverflow.com/questions/9337418/access-html-controls-from-code-behind-c-sharp