zoukankan      html  css  js  c++  java
  • .Net定时弹出窗口(c#)

    .Net定时弹出窗口(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 TimeInterval=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
     }
    }

  • 相关阅读:
    IE hack [if IE]解决IE CSS 兼容问题
    jQuery重要插件、JS辅助工具
    几个jQueryUI框架
    推荐书籍
    Win7下用原生的ie6调试网页
    Code First :使用Entity. Framework编程(3)
    Code First :使用Entity. Framework编程(6)
    JSON数据格式转换
    Code First :使用Entity. Framework编程(5)
    Code First :使用Entity. Framework编程(4)
  • 原文地址:https://www.cnblogs.com/winner/p/660234.html
Copyright © 2011-2022 走看看