Work on Asp.Net C# VS08 I would like to assign a value to Session using javascript. Is it possible?
example: Session["Id"] = document.getElementById("id").value;
Work on Asp.Net C# VS08 I would like to assign a value to Session using javascript. Is it possible?
example: Session["Id"] = document.getElementById("id").value;
Assigning to a session variable like this isn't possible in JavaScript. Best you can do is write data to a cookie.
http://www.w3schools.com/js/js_cookies.asp
Otherwise if you want to communicate to the server use Ajax.
No it is not possible to do that directly with JavaScript on the client-side.
Sessions are handled on the server-side. In general your browser would simply store a cookie which uniquely identifies a session stored on your server. When you change the value of a session variable, you are storing this on the server, and the browser cookie would be unaffected.
You could however use JavaScript to send an XMLHttpRequest to your ASP.NET application, which in turn changes the session variable on the server-side. Since this involves a round-trip to the server, you would have to wait for the response, to confirm that the operation succeeded.
The session is a server-side concept; Javascript has no conception of it.
You can make an AJAX service that sets a session value.
However, you should probably use a cookie instead.
You can set cookies in Javascript using this library, among others.
No it is not possible. Session is server side object. A couple of ways to do that would be to send cookies from JavaScript and use them on the server side to assign a value to a session variable, or to make an AJAX call and set the values on the backend.