The problem is although SessionKey comes back ok, reading the others does not when I read back in the same fashion...
the_item1 = '<%=Session("Session1")%>';
the_item2 = '<%=Session("Session1")%>';
When these lines are added, it messes up the Javascript and makes the lines after it not work properly (some lines execute, some don't).
So 2 questions:
1.) What is the proper way to handle session variables across VB/C# to Javascript?
2.) Someone mentioned that you shouldn't use the OnLoad= in the <body> tag, because it sometimes fires sometimes doesn't or is unreliable in some way. Is that true? If so, what is the proper way to handle onload to exectute a Javascript function on page
load. This may account for some of the issues I am seeing.
realtimewire...
Member
10 Points
2 Posts
Write session in VB/C#, read session in Javascript - What is Proper Way?
Feb 08, 2006 03:11 AM|LINK
I've got an app that gets some information and stores it into 2 variables, then writes this information to a session variable, all via VB.
I then try to retrieve the session variable via Javascript and C#.
It works, but it's flakey. 1.) am I doing this correctly? 2.) is there a better way?
Here's the code that writes the session variable out:
Session.Add("Session1", it1
Session.Add("Session2", it2)
I also used
Session("SessionKey") = 123
Then I read back via JavaScript using...
user_id = '<%=Session("SessionKey")%>';
The problem is although SessionKey comes back ok, reading the others does not when I read back in the same fashion...
the_item1 = '<%=Session("Session1")%>';
the_item2 = '<%=Session("Session1")%>';
When these lines are added, it messes up the Javascript and makes the lines after it not work properly (some lines execute, some don't).
So 2 questions:
1.) What is the proper way to handle session variables across VB/C# to Javascript?
2.) Someone mentioned that you shouldn't use the OnLoad= in the <body> tag, because it sometimes fires sometimes doesn't or is unreliable in some way. Is that true? If so, what is the proper way to handle onload to exectute a Javascript function on page load. This may account for some of the issues I am seeing.
Thank you
Fitzgerald Engineering, LLC