ASP.NET 验证控件与防止按钮连按两次送出
前阵子在网络上看到一篇不错的文章...
介绍ASP.NET使用验证控件时与防止按钮连按两次送出的问题
在此分享此篇文章给大家呀....
数据来源:http://www.ithome.com.tw/plog/index.php?op=ViewArticle&articleId=11012&blogId=418
小弟也做了一个实例测试一下...如下:
c#范例
.aspx
01 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="doubleClick.aspx.cs" Inherits="doubleClick" %>
02
03
04
05
06???? 未命名页面
07
08
09????
10????????
11???????????? 12???????????????? runat="server" ControlToValidate="TextBox1" ErrorMessage="不可为空白">
13????????????
14????
15
16
17
18
32
33
.cs
01 using ...System;
02 using System.Data;
03 using System.Configuration;
04 using System.Collections;
05 using System.Web;
06 using System.Web.Security;
07 using System.Web.UI;
08 using System.Web.UI.WebControls;
09 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 public partial class doubleClick : System.Web.UI.Page
13 ...{
14 ????protected void Page_Load(object sender, EventArgs e)
15 ????...{
16 ????????this.Button1.Attributes.Add("onclick", "check(this);");
17 ????}
18 ????protected void Button1_Click(object sender, EventArgs e)
19 ????...{
20 ????????//模拟数据库保存,处理时间5秒
21 ????????System.Threading.Thread.Sleep(5000);
22 ????????Response.Write(this.TextBox1.Text);
23 ????}
24 }
原文:大专栏 ASP.NET 验证控件与防止按钮连按两次送出