. Net timed pop-up window (c #)

Source: Internet
Author: User
. 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
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.