Set session variables

D

DS

In client-side script (<script> codes </script>), how can set / get session
variables' values? Pls advise.

DS
 
B

Bhaskardeep Khaund

Hi,

If your are using JavaScript, you can assign the value for ur ASP session variable into a JavaScript variable and then work on it.
Like

<script>
var name;
name = "<%=Session("name")%>"
........

</script>

Bhaskardeep Khaund
 
D

DS

But, how can I assign a variable or values to a session variable within a client-side script? For example

<script>
//Java script
document.write ("<%Session("ItemCode") = " + strTest + "%>")
</script>
Any wrongs here?

DS
"Bhaskardeep Khaund" <[email protected]> 在郵件 中撰寫...
Hi,

If your are using JavaScript, you can assign the value for ur ASP session variable into a JavaScript variable and then work on it.
Like

<script>
var name;
name = "<%=Session("name")%>"
.......

</script>

Bhaskardeep Khaund
 
B

Bhaskardeep Khaund

Hi,

How can you assign a Session variable to a client-side variable. Since, session would be executed on the server-side and your JS scripts would be executed on the clients computer. I think u cant do that.

Bhaksardeep Khaund
 
D

DS

Then, how can I pass a value, which is got in client-side, to server-side? Can I call a client-side function, which returns a value, in server-side script? Actually, I am in trouble on how to communicate between client and server sides script very well....please advise.

Thanks,
DS
"Bhaskardeep Khaund" <[email protected]> 在郵件 中撰寫...
Hi,

How can you assign a Session variable to a client-side variable. Since, session would be executed on the server-side and your JS scripts would be executed on the clients computer. I think u cant do that.

Bhaksardeep Khaund
 
B

Bob Barrows

DS said:
In client-side script (<script> codes </script>), how can set / get
session variables' values? Pls advise.

DS

There was a technique posted sometime in the last couple weeks for setting a
session variable via an IMG tag on the page. I'll see if I can find it
later.

In the meantime, you can also use XMLHTTP to pass a value to a server-side
page which can then set a session variable. A Google search, or a visit to
www.aspfaq.com, should provide you with a few examples.


To pass a session variable's value to client-side script, simply
response.write it:

client_side_var = "<%=session("var")%>"

HTH,
Bob Barrows
 

Ask a Question

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.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top