C
Craig G
if so, how?
You cannot access Session directly from client side script. However, youCraig said:if so, how?
Anders Norås said:You cannot access Session directly from client side script. However, youCraig said:if so, how?
can generate JavaScript code to assign the value of the Session variable
to a client side variable. If you change the client side variable,
you'll have to post the new value back in order to update the Session.
Here is a simple example which creates a JavaScript variable with the
value of a Session variable:
<%@ Page language="c#" AutoEventWireup="true" %>
<script runat="server">
void Page_Load()
{
Session["MySessionVar"]="Hello world";
}
</script>
<html>
<script language="JavaScript">
var mySessionVar="<%= Session["MySessionVar"] %>";
</script>
<body>
<form runat="server"></form>
</body>
</html>
Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.