zoukankan      html  css  js  c++  java
  • Check F5 refresh submit post back repeatly

    
    <%@ Page language="c#" AutoEventWireup="true"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
     <HEAD>
      <title>Check F5 refresh submit post back repeatly</title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     <script language="C#" runat="server">
     private bool _IsF5RefreshPostBack;
     protected void Page_Load(object sender, EventArgs ea) 
     {
      if (IsPostBack)
      {
       if (Request.Cookies["cookieTimeStamp"] != null)
       {
        //if (Request.Cookies["cookieTimeStamp"].Value != this.label1.Text)
        //不用ViewState 使用 HiddenField 也可
        if (Request.Cookies["cookieTimeStamp"].Value != (string) ViewState["vsTimeStamp"])
        {
         _IsF5RefreshPostBack = true;
        }
       }
      }
      string timeStamp = DateTime.Now.ToString();
      //this.label1.Text = timeStamp;
      ViewState["vsTimeStamp"] = timeStamp;
      HttpCookie cookie = new HttpCookie("cookieTimeStamp", timeStamp);
      Response.Cookies.Add(cookie);
      
      if (_IsF5RefreshPostBack)
      {
       Response.Write("IsRefreshPostBack(F5) in Page Load<br>" );
      }
     }
     void button1_Click (object sender, EventArgs ea) 
     {
      if (_IsF5RefreshPostBack)
      {
       Response.Write("IsRefreshPostBack(F5) in Button Click<br>" );
      }
     }
    </script>
     </HEAD>
     <body>
      <form id="Form1" method="post" runat="server">
        <asp:Button ID="button1" Text="button1" onclick="button1_Click" runat="server" />
      </form>
     </body>
    </HTML>
    
    
  • 相关阅读:
    Android之Wifi使用
    Android之浮动小窗口
    Android之Socket的基于UDP传输
    Android之基本常见知识(持续更新)
    Android之打开闪光灯关键代码
    Android之Oauth验证(一)
    Android之WebView简易应用
    Android之短信广播接收内容
    Google HTML/CSS 代码风格指南
    几个 HTML 标签的用法
  • 原文地址:https://www.cnblogs.com/Microshaoft/p/1311243.html
Copyright © 2011-2022 走看看