Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call code behind from javascript timer 1

Status
Not open for further replies.

codecomm

Programmer
Feb 14, 2007
121
US
I've had a lot of help with some session timeout issues from other postings. Thank you to all who have responded and given input. Everything is helpful!

What I'd like to do is have a time via javascript that calls an Update/Save routine at 19 minutes of inactivity.

We've left our Session timeout value to 20 minutes, and it's been asked if we can simply save/update data automatically, so if the user session times out in another minute, they haven't lost any data entry.

I know how to show a client side pop-up warning at 15 minutes, but haven't figured out how to make the client side javascript call something in code behind.

Thanks!
 
I'm trying the following and get a javascript error about the myHiddenButtonID is not defined:

*****

HTML

******

</head>

<!-- Start timeout code -->

<body onmousedown = "window_activity()" onkeypress="window_activity()">

<script type="text/javascript">

var timerPROMPT = 0;

var timerCLOSE = 0;

function EndApp(){

//RateDeck.style.display = "none"

//spDeck.style.display = "none"

}

function StopTiming(){

if(timerPROMPT > 0)

window.clearTimeout(timerPROMPT)

//call button

var myHiddenButton = document.getElementById(myHiddenButtonID);

myHiddenButton.Click()

//end button call

if (confirm('Due to inactivity, your session is about to time out.')== 1)

{

if(timerCLOSE > 0)

window.clearTimeout(timerCLOSE)

timerPROMPT = window.setTimeout("StopTiming()",5000);

timerCLOSE = window.setTimeout("EndApp()",8000);

}

else

{

EndApp();

}

}

function window_activity() {

if(timerPROMPT > 0)

window.clearTimeout(timerPROMPT)

if(timerCLOSE > 0)

window.clearTimeout(timerCLOSE)

timerPROMPT = window.setTimeout("StopTiming()",5000);

timerCLOSE = window.setTimeout("EndApp()",6000);

}

</script>

<!-- End timout code -->

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<div>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:Button ID="myHiddenButtonID" runat="server" Font-Size="XX-Small" OnClick="myHiddenButtonID_Click"

Text="Hide" /><br />

<br />

<br />


<asp:Image ID="Image1" runat="server" ImageUrl="~/images/top.jpg" />

</div>

</form>

</body>

</html>



*****

Code behind

****

protected void myHiddenButtonID_Click(object sender, EventArgs e)

{

Response.Write("Hidden button click event!");

}
 
Try asking in the javascript forum for any javascript issues you have. They will also want to see your client-side rendered HTML, not your ASP.NET code.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
So, just changed the javascript to:

//call button

var myHiddenButton = document.getElementById("myHiddenButtonID");

myHiddenButton.OnClick();

//end button call

..and tried:

myHiddenButton.Click();


..and now I get the object doesn't support this proptery or method in a javascript error
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top