Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Set session variables

Reply
Thread Tools

Set session variables

 
 
DS
Guest
Posts: n/a
 
      12-03-2003
In client-side script (<script> codes </script>), how can set / get session
variables' values? Pls advise.

DS


 
Reply With Quote
 
 
 
 
Bhaskardeep Khaund
Guest
Posts: n/a
 
      12-03-2003
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
 
Reply With Quote
 
 
 
 
DS
Guest
Posts: n/a
 
      12-04-2003
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" <(E-Mail Removed)> 在郵件 news:(E-Mail Removed) *撰寫...
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
 
Reply With Quote
 
Bhaskardeep Khaund
Guest
Posts: n/a
 
      12-04-2003
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
 
Reply With Quote
 
DS
Guest
Posts: n/a
 
      12-04-2003
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" <(E-Mail Removed)> 在郵件 news:eQo67%(E-Mail Removed) *撰寫...
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
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      12-04-2003
DS wrote:
> 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

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Session Variables and Static Variables cobus.lombard@gmail.com ASP .Net 1 03-26-2006 11:05 AM
RE: Session Variables assigned to the wrong session? Robert Faulkner ASP .Net 0 01-28-2005 04:16 PM
Session Variables assigned to the wrong session? =?iso-8859-15?Q?Fabr=EDcio_de_Novaes_Kucinskis?= ASP .Net 1 01-20-2005 04:33 PM
Global Session Variables and Session State Earl Teigrob ASP .Net 1 12-17-2003 07:02 AM



Advertisments