Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Passing Session variables (ASP.NET)

Guest
Jan 21, 2010 Jan 21, 2010

Hi,

I've been working on a site for quite a while and am a fair way in using Javascript. However I thought I'd check out a bit of asp.net as it has quite a few functions that seem easier to implement than in Javascript.

I have a login page created using the built-in server behaviours that sets a session variable in Javascript using the following line of code:

Session("MM_Username") = MM_valUsername;

This variable is avalable to all other javascript pages and I can disply the variable on a page by placing this lin eof code within the HTML:

<%= Session("MM_Username") %>

However the one page that I have created using vb.net will not display the variable. The code I'm using is this:

<% =Session("MM_Username")%>

Is there a reason for this or am I just doing something wrong?

Thanks in advance

Dan

TOPICS
Server side applications
805
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 21, 2010 Jan 21, 2010

Ahhhh ha! I think I've found the answer but would like someone who knows what they're on about to confirm for me.

I believe the reason I can't pass a variable is because Javascript is executed on the browser, so the session variable is set on the local PC.

ASP.net on the other hand is executed on the server. So a session variable set in Javascript code has no way of getting to the server ?

So the only way I can see that I can pass a variable would be to use a QueryString which would be picked up by the ASP page... I think

Cheers

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 21, 2010 Jan 21, 2010

This doesn't make sense. You say you are using a "server behavior" that sets a "client side session" using javascript. Are you sure this isn't ASP/JScript?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 22, 2010 Jan 22, 2010
LATEST

Hi bregent, thanks for taking the time to read and respond.

I suspect I'm using the wrong terminology! The login page where the session variable is set has an ASP extention, but according to the first line of code its Javascript

<%@LANGUAGE="JAVASCRIPT"%>

Soooo...errrrr.... Jscript or javascript... ??

Cheers

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines