Reference Library
SanibelLogic Namespace
NamespacesSanibelLogic
Declaration Syntax
C#Visual BasicVisual C++
namespace SanibelLogic
Namespace SanibelLogic
namespace SanibelLogic
Types
All TypesClasses
IconTypeDescription
ClientTime

ClientTime injects JavaScript code for creating a browser cookie containing the browser's local time zone. ClientTime also provides web server based C# methods for determining whether the browser's local time zone was available and for translating date/times from various time zones to the browser's local time zone. ClientTime solves a much needed web server problem of needing to know the browser's local time zone so that web response date/times can be expressed in the browser's local time.

At the start of a browser session the time zone cookie is created and the current URL is reloaded for purposes of sending the time zone cookie to the web server. This URL reload will result in duplicate Page_Load event handlers being driven in the target ASP.NET application; the first Page_Load for the original URL web query GET and the second Page_Load for the reload URL web query GET. Subsequent web query GETs within the same browser session will only result in a single Page_Load event handler being driven. The browser cookie created by ClientTime currently expires by the end of a browser session.

This ASP.NET custom control is based on a January 2007 article in ASP.NetPro magazine entitled "Its About Time". The article discusses the JavaScript requirements for such an implementation. I take the article a step further by encapsulating C# support methods and JavaScript injection code into the form of an ASP.NET custom control.