New .NET 4.0 version available here.
UPDATE: 9/27/2009 10:16PM
I originally posted this control using the jCountr jquery plugin to handle the countdown timer for me. Since then it has been brought to my attention that there were issues with this approach. Not to say the problems were from the jCountr plugin itself, but most likely my implementation of it. Regardless, I have since abandoned the jCountr plugin approach and reverted to plain javascript for handling the countdown timer. This seems to work better and give me more control over the process as well. Both attached zip files have been updated accordingly.
END UPDATE
This is my second iteration of what was originally Travis Collins' ASP.NET Session Timeout Control.
Note: You may want to read through my original post about version1 of this control as I will only be covering changes here in this post.
Essentially, v1 expanded upon Travis' original design and replaced a simple timeout warning div with a jQuery UI Dialog popup.
Based upon feedback from several users (and my own continued use of the control), I now present to you v2 of this control.
The first and most notable change is a countdown timer. If enabled, when the warning popup appears - it will countdown the time remaining until session timeout so that users can clearly see exactly how long they have left. Of course the timer calculates its countdown time based on the Timeout control's settings (which actually comes from the normal Session tag in your web.config).
The countdown timer is implemented using a new property on the control called CountDownSpanID. This controls the span element used to display the countdown timer. *Note this setting is completely optional.
The next change is the ability to control whether async/partial postbacks reset session.
This is also implemented via a new property on the control - ResetSessionOnAsyncPostback.
ResetSessionOnAsyncPostback is a boolean value that defaults to TRUE. This means even if you don't set it - the control will work just as it did in version1.
The last change is a very simple property called DirtyFormSpanID. When set, the specified span will be given a value of "False" just prior to the timeout redirect. I use this option in conjunction with other special purpose code to implement dirty form warnings if a user attempts to leave a page with unsaved changes. Please understand this control does not implement any type of dirty form warning. ALL this option does is set a span value to "False" upon timeout redirect. Obviously, this setting is completely optional.
Here's an example of how to set all three of the new properties, as well as how to easily add the span for the countdown timer:
Just remember to add references to your script files (jquery, jqueryUI, bgiframe) and you should be good to go.
<tsc:Timeout ID="Timeout1" runat="server" title="Session Expiring" Enabled="true" TimeoutURL="~/TimeOut.aspx" ResetSessionOnAsyncPostback="true" CountDownSpanID="tscCounter" DirtyFormSpanID="dirtyForm">
<Template>
<p>
<span class="ui-icon ui-icon-alert" style="float:left; margin: 1px 10px 20px 0;"></span>
Your session is about to Expire.
</p>
<span id="tscCounter"></span>
<p>Click <b>OK</b> to continue your session.</p>
</Template>
</tsc:Timeout>
Oh one more thing, if you're upgrading from the first version of my control, be aware I bumped the version number so you'll need to redo the reference to the dll.
That's it.
Full Timeout Control project (source, dll's, etc):
Full working Web App solution demonstrating usage: