Solved

asp.net - session countdown timer

Posted on 2009-05-03
2
1,205 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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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