views:

200

answers:

2

Hey guys. 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?

A: 

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.

Matt
+1  A: 

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)

SLaks
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
@BuzzedWord: Exactly. If this answer solved your problem, you should accept it by clicking the hollow check.
SLaks
Yup. It just did, and I am. Thanks!
Buzzedword