. Net timed pop-up window (c #)
Using System;
Using System. Collections;
Using System. ComponentModel;
Using System. Web;
Using System. Web. SessionState;
Using System. Threading;
Using System. Timers;
Namespace PopUp
{
Public class Global: System. Web. HttpApplication
{
Private System. ComponentModel. IContainer components = null;
Private System. Timers. Timer aTimer;
Public static DateTime dtBegin;
Public static long timeinteger = 10000;
Public static bool TimeOut;
Public Global ()
{
InitializeComponent ();
}
Protected void Application_Start (Object sender, EventArgs e)
{
TimeOut = false;
DtBegin = DateTime. Now;
ATimer = new System. Timers. Timer ();
ATimer. Elapsed + = new ElapsedEventHandler (OnTimedEvent );
ATimer. Interval = TimeInterval;
ATimer. Enabled = true;
}
Protected void Session_Start (Object sender, EventArgs e)
{
}
Protected void Application_BeginRequest (Object sender, EventArgs e)
{
If (TimeOut = true)
{
TimeSpan ts = DateTime. Now-dtBegin;
String str = "<script> alert ('you have been in this application ";
Str = str + ts. Hours + "hours" + ts. Minutes + "minutes" + ts. Seconds + "seconds! ') </Script> ";
Response. Write (str );
TimeOut = false;
}
}
Protected void Application_EndRequest (Object sender, EventArgs e)
{
}
Protected void Application_AuthenticateRequest (Object sender, EventArgs e)
{
}
Protected void Application_Error (Object sender, EventArgs e)
{
}
Protected void Session_End (Object sender, EventArgs e)
{
}
Protected void Application_End (Object sender, EventArgs e)
{
This. aTimer. Enabled = false;
}
Private void OnTimedEvent (object source, ElapsedEventArgs e)
{
TimeOut = true;
}
# Region Web Form Designer generated code
Private void InitializeComponent ()
{
}
# Endregion
}
}