Solved

asp.net - session countdown timer

Posted on 2009-05-03
2
1,202 Views
Last Modified: 2012-08-14
We have an asp.net application written in vb.net 2008 against framework 3.5

We use master pages. We want to have a countdown on the master page which resets to 20 minutes each postback and starts counting down so the user knows when their session will expire. We have a label in a Table cell which is the label to be updated. I can change this from a server label to an html label if this will make it easier.

I tried a few examples but couldnt get the thing to go. Can anyone show me one which will work in the environment i mentioned above?
0
Comment
Question by:tfsln
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
ppittle earned 500 total points
ID: 24292618
I'd recommend adding a countdown timer JavaScript function/ GUI element to your masterpage code behind.  Each time you build out the JavaScript, you can set (and re-set) the countdown timer.
There are numerous examples of javascript timers all over the web, for example:
http://www.hashemian.com/tools/javascript-countdown.htm

Using that example, I mocked up an example of how to dynamically add it to the page each time. :
<%@ page %>
<html>
<head runat="server">
<asp:Label ID="CountDownTimerJavaScriptLabel" runat="server" />
</head>
<body></body>
</html>

<%-- Code Behind --%>
protected void Page_Load(object sender, EventArgs e)
{
CountDownTimerJavaScriptLabel.Text =
"<script language="JavaScript">" +
"TargetDate = \"" + DateTime.Now.AddMinutes(20).ToString() + "\";" +
"BackColor = \"palegreen\";" +
"ForeColor = \"navy\";" +
"CountActive = true;" +
"CountStepper = -1;" +
"LeadingZero = true;" +
"DisplayFormat = \"%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.\"; " +
"FinishMessage = "It is finally here!"; " +
"</script> " +
"<script language=\"JavaScript\" src=\"http://scripts.hashemian.com/js/countdown.js\"></script> ";

}
0
 
LVL 3

Expert Comment

by:GregTSmith
ID: 24292733
I had a little different impression of what you were looking for and have attached it.
CountdownTimer.htm.txt
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question