0

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!

5
  • As matthew states, you will have to send the code back from the user to the server somehow. One way to do this is with AJAX. You can also do it with an XmlHttpRequest. Commented Feb 18, 2012 at 0:47
  • @TravisJ, just so you know XmlHttpRequest is the technology that makes AJAX possible. They are not really different things. But yeah, AJAX is the right solution to this problem. Commented Feb 18, 2012 at 0:51
  • @BenLee - I know, but sometimes people don't like to include libraries and just want to use plain javascript. Commented Feb 18, 2012 at 0:53
  • Why do you want to access the HTML generated by jQuery from the server? Do you really need more than the form data? Commented Feb 18, 2012 at 6:33
  • Yeh...I have no choice. The web developer wrote like 2000 lines of JS and jQuery code that is quite out of my understanding...So, I have to do crazy stuff with the crazy code he wrote....But after further analyzing, I think it would be better to just do Javascript rather than doing server side code....THanks for the suggestions :D Commented Feb 20, 2012 at 21:31

1 Answer 1

3

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"].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.