1

I'm trying to access the innerHTML of a span tag modified by jQuery using C#. This is my first project shunning the AJAX libs in favor of jQuery, so I'm not sure how I can get the codebehind to recognize the manipulated innerHTML. I've set all the spans I want to tap into with runat="server", but all I pull are the values I've set when the page was designed.

What steps should I be taking to enable communication between the client-side and my codebehind, and am I even using the best practice here?

0

2 Answers 2

2

When the browser submits a form to the server, it only sends the values of non-disabled form fields. (<input>, <select>, and <textarea> tags)

It does not send anything else.
If you want to send your jQuery-modified HTML to the server, you'll need to use Javascript to put it into a hidden <input> field. (Or use AJAX)

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

3 Comments

I like that. For example, when you click a span tag in my form, it fires a jquery event (with a dynamic form field). After completing the form field, it changes the innerHTML for the span. So what you're saying, is that in the same statement that changes the innerHTML, set the value for a hidden input field?
@BuzzedWord: Exactly. If this answer solved your problem, you should accept it by clicking the hollow check.
Yup. It just did, and I am. Thanks!
0

The value of .NET labels are stored in the viewstate, so won't be able to change them on the client side. You could try making a hidden field or textbox to hold the value for you instead.

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.