Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 09:54 AM
DS
Guest
 
Posts: n/a
Default Set session variables

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

DS


  #2  
Old July 19th, 2005, 09:55 AM
Bhaskardeep Khaund
Guest
 
Posts: n/a
Default Re: Set session variables

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
  #3  
Old July 19th, 2005, 09:56 AM
DS
Guest
 
Posts: n/a
Default Re: Set session variables

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" <bhaskar_999@hotmail.com> 在郵件 news:OliKG6ZuDHA.2448@TK2MSFTNGP12.phx.gbl ä¸*撰寫...
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
  #4  
Old July 19th, 2005, 09:57 AM
Bhaskardeep Khaund
Guest
 
Posts: n/a
Default Re: Set session variables

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
  #5  
Old July 19th, 2005, 09:57 AM
DS
Guest
 
Posts: n/a
Default Re: Set session variables

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" <bhaskar_999@hotmail.com> 在郵件 news:eQo67%23kuDHA.3224@tk2msftngp13.phx.gbl ä¸*撰寫...
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
  #6  
Old July 19th, 2005, 09:57 AM
Bob Barrows
Guest
 
Posts: n/a
Default Re: Set session variables

DS wrote:[color=blue]
> In client-side script (<script> codes </script>), how can set / get
> session variables' values? Pls advise.
>
> DS[/color]

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"


 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles