Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-11-2010, 04:20 PM   PM User | #1
M007
New to the CF scene

 
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
M007 is an unknown quantity at this point
Accessing Session variable from javascript

Hi,

I'm making my first ASP.NET web application. I read in several forums that it is possible to access a Session variable from javascript by using the following syntax:

var a = '<%=Session("Village")%>';

However, variable 'a' gets the value "<%=Session("Village")%>" instead of the value of Session variable 'Village'.

Any ideas what I'm doing wrong?

Thanks in advance!
M007 is offline   Reply With Quote
Old 08-11-2010, 06:04 PM   PM User | #2
accwebworks
New Coder

 
Join Date: Mar 2010
Location: nyc
Posts: 31
Thanks: 0
Thanked 1 Time in 1 Post
accwebworks is an unknown quantity at this point
Make sure that your javaScript code is on a page that is is being processed by .net. It has to end with .aspx.
accwebworks is offline   Reply With Quote
Old 08-29-2010, 12:37 PM   PM User | #3
rrajwar
New to the CF scene

 
Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
rrajwar is an unknown quantity at this point
its correct.
<script>
var MyClientSideVar = <%= Session("MySessionVar")%>;
alert(MyClientSideVar);
</script>
rrajwar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 05:02 AM.


Advertisement
Log in to turn off these ads.