• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

js syntax error within Visual Studio 2012

Hello,

I'm getting a syntax error in the bold items below in my .js file.  I'm working within Visual Studio 2012.

function SetPageTimes()
{
    msecPageLoad = new Date().getTime();

    msecTimeOut = (<%=Session.Timeout%> * 60 * 1000); // The page will time out depends on the value of Session.Timeout parameter in web.config

    msecWarning = (<%=Session.Timeout%> * .95 * 60 * 1000); // The warning message will pop up after passing 95% of the total time
}

Let me know if you need additional information.
I appreciate any help.  Thanks.
0
javierpdx
Asked:
javierpdx
2 Solutions
 
leakim971PluritechnicianCommented:
what about :

function SetPageTimes() 
{
    msecPageLoad = new Date().getTime();
    var x = "<%=Session.Timeout %>";
    msecTimeOut = x * 60 * 1000; // The page will time out depends on the value of Session.Timeout parameter in web.config
    msecWarning = x * .95 * 60 * 1000; // The warning message will pop up after passing 95% of the total time
}

Open in new window

0
 
GaryCommented:
If this is a seperate js file then it does not have access to the ASP variables.

Store the Session.Timeout in an hidden field with an ID and then reference the input in your js file

document.getElementById("session_timeout_input_id").value

Open in new window

msecTimeOut = (parseInt(document.getElementById("session_timeout_input_id").value) * 60 * 1000); 

Open in new window

Otherwise add some js to the actual .net page and store the timeout in a global var that you can reference in the external file.

Though since the timeout never really changes why not just hardcode the value?
0
 
javierpdxAuthor Commented:
Thanks for the help.  I had considered hard coding it but was looking for a different solution.   I'll just hard code it.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now