Link to home
Create AccountLog in
Avatar of OB1Canobie
OB1CanobieFlag for United States of America

asked on

Using Session Variable in JavaScript

I have a web page for asp.net vb. I have a session variable "ProjectID" that I need to access for a path in JavaScript. Can someone assist in how to access the session variable in the building of the path. I am assigning a variable the path. See what I have thus far. I need the session variable value as indicated. Thanks.

var newhref = ("../forms/form_task_utility.aspx?Mode=A%ProjectID="  %>);
ASKER CERTIFIED SOLUTION
Avatar of Sudhindra A N
Sudhindra A N
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Rainverse
Rainverse

Another way I've used is to have a hidden field on the form with a runat="server" in it, and set the value in the code behind.  I try to avoid in-line code and keep my .Net code separated in the code behind as much as possible. Then to retrieve, just get the value in the js:

pID = document.getElementById("hProjID").value;
var newhref = ("../forms/form_task_utility.aspx?Mode=A&ProjectID=" + pID);

-MJC