0

I have an asp.net c# website that I am having a problem getting the jscript to execute. I have a masterpage that loads that contains the javascript and the code. A code excerpt is below. When it runs, the timer never shows up. If I click the close page button, I get an error that says:

Microsoft JScript runtime error: The value of the property 'closePage' is null or undefined, not a Function object.

on the line:

<input type="submit" name="ctl00$CloseSection$btnClose" value="Close Page Now" onclick="closePage(); return false;" id="ctl00_CloseSection_btnClose" class="buttons" />

I have tried many things, moving the .js src line above and below the var section. NOthing seems to change this. The strange thing is this worked fine just a few days ago. I noticed that MS made several VS updates on 9/14.

Any help would be appreciated.

I can do a view source and the js line shows up fine:

 <script src="jscripts/StoreFrontClose.js" type="text/javascript"></script>

The source excerpt is below:


<asp:ContentPlaceHolder ID="CloseSection" runat="server">
 <script src="jscripts/PageClose.js" type="text/javascript"></script>

<script type="text/javascript" language="javascript">
  var timeoutMins = 0;
  var timeoutSecs = 30;
alert("getting ready to start timer");
if (source == "kiosk") {
  startPageCloseTimer();
}              
<div style="text-align: center;">
 The Page will close in: <span id="theTime" class="timeClass"></span>
    <br />
  <asp:Button ID="btnClose" CssClass="buttons" runat="server" OnClientClick="closePage();"
                        Text="Close Page Now" />
 <asp:Button ID="btnKeepOpen" CssClass="buttons" runat="server" OnClientClick="resetTimer();"
                        Text="Keep Page Open a little Longer" />
</div>
</asp:ContentPlaceHolder>

the PageClose.js has:

    function startPageCloseTimer() {
    alertTimerId = setTimeout("AlertUser()", timeoutMilli);
    countDown();
}

function AlertUser() {
    extend = false;
    handleTimerId = setTimeout("HandleTimeout();", maxPopupTime);
    jQuery("#messagePopup").dialog("open");
}

function HandleTimeout() {
    if (!extend) {
        closePage();
    }
}

function KeepSessionAlive() {
    extend = true;
    resetTimer();
}



function resetTimer() {

    clearTimeout(alertTimerId);
    clearTimeout(handleTimerId);
    alertTimerId = setTimeout("AlertUser()", timeoutMilli);
    sec = timeoutSecs;
    min = timeoutMins;
    countDown();
}

function closePage() {
alert("getting ready to close page");
clearTimeout(handleTimerId);
clearTimeout(alertTimerId);
clearTimeout(countDownTimerId);
}

var sec = timeoutSecs; //   set the seconds
var min = timeoutMins; // set the minutes

function countDown() {
    sec--;
    if (sec == -01) {
        sec = 59;
        min = min - 1;
    } else {
        min = min;
    }
    if (sec <= 9) { sec = "0" + sec; }
    var time = "";
    if (min > 0) {
        time = (min <= 9 ? "0" + min : min) + " min and ";
    }

    time = time + sec + " sec ";

    if (document.getElementById("theTime")) {
        document.getElementById("theTime").innerHTML = time;
    }
    countDownTimerId = window.setTimeout("countDown();", 1000);
    if (min == '00' && sec == '00') {
        sec = "00";
        window.clearTimeout(countDownTimerId);
    }
}
1
  • 1
    Missing a closing script tag in the source excerpt. Commented Sep 17, 2011 at 1:54

1 Answer 1

1

You simply forgot the closing </script> tag:

<script src="jscripts/PageClose.js" type="text/javascript"></script>

<script type="text/javascript" language="javascript">
    var timeoutMins = 0;
    var timeoutSecs = 30;
    alert("getting ready to start timer");
    if (source == "kiosk") {
        startPageCloseTimer();
    } // end of script
</script> // close tag
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.