That's a lot of questions in one question... Let me try to tackle them all.
First of all, you *can* share variables between server side and client side code, but not directly. It's important to understand how it works under the hood if you want to share the values of these two kind of variables.
of those variables from the server to the client and back.
Let me clarify this with an example. The following piece of code will alert the value of a Session variable:
Session("MyTest") = Now() ' store date and time in session var
var whatTimeIsIt = '<%=Session("MyTest")%>';
code block (<%= and %>) which injects the value of the session variable into the client side code.
If you look at the source of the page in the browser, you'll see something like this:
var whatTimeIsIt = '4/1/2004 9:32:06 AM';
So, as you can see, you can pass the value of the session variable into a local variable.
) virtually endless. I am not aware of any limitation. However, you should be aware of some encoding issues, for example::
Session("MyTest") = "A variable's value"
var whatValue = '<%=Session("MyTest")%>';
This will cause a problem because the MyTest variable contains an apostrophe. The code in the browser will end up like this:
var whatValue = 'A variable's value';
As you can see, the value is cut of after the word variable, as the ' is seen as the end of the string.
Therefor it's important to escape any output you're trying to send to the browser. You can use Escaping methods or replace the illegal characters yourself.
If you need to send the client side value back to the server, you'll need to add it to a form somehow. How you do this is up to you: you can write out the server side variables to hidden or visible fields, allow the user to change them (or not), have the client recalculate them, whatever your application requires. At the end, the variables must be added to the form, and submitted back to the server. There, the same principle applies again, but in reverse:
' Assume form is submitted
Session("MyTest") = Request.Form("txtHiddenMyTest")
This saves the value of the hidden form field back in the server side session variable.
I think this answers all your question you asked here. If not, let me know.
Everyone is unique, except for me.