易截截图软件、单文件、免安装、纯绿色、仅160KB

防止ASP.NET按钮多次提交的办法

 
 对“添加”、“提交”、“保存”、“更新”等按钮需要对数据库进行写操作的按钮,一定要在页面初始化时加载脚本,防止多次重复点击,例如:
   protected void Page_Load(object sender, EventArgs e)
{
//.net 2.0以上
Button1.Attributes.Add("onclick", "this.disabled=true;" + this.ClientScript.GetPostBackEventReference(Button1, ""));
}

测试页面:
  为了测试,我们可以建立一个页面,加入一个btnAdd按钮   
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddAndEditUser.aspx.cs" Inherits="AddUser" %><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>添加和编辑页面示例</title>
</head>
<body>
<form id="frmMain" runat="server">
<asp:Button ID="btnAdd" runat="server" CssClass="INPUT-BUTTON-Save" OnClick="btnAdd_Click">
</asp:Button>
</form>
</body>
</html>
/*----------------------------------------------------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class AddUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnAdd.Attributes.Add("onclick", "this.disabled=true;" + this.ClientScript.GetPostBackEventReference(btnAdd, ""));

}
protected void btnAdd_Click(object sender, EventArgs e)
{
//模拟网络拥塞5秒钟
System.Threading.Thread.Sleep(5000);
}
}
 
    还有可以用Javasc


相关文档:

asp.net成长日记

1、建立数据层 连接数据库->建立数据集*.xsd->表中建立查询方法
2、建立业务逻辑层 包装TableAdapter方法成类
3、建立母板页和站点导航( CSS待学习)
4、使用数据源展现数据 五种数据源 编辑数据源参数 使用tableadapter方法
5、使用dropDownList过滤主-从报表
     使用tableadapter方法 ......

vs2005不能调试ASP.NET程序

解决方法:
1.看看你的Terminal Services服务启动没有,如果没有启动就可以解决问题。
2确认  Machine  Debug  Manager  服务已启动
3、打开项目属性,在“Debug”(调试)一项里,把“Enable the Visual Studio hosting process”(启用Visual Studio 宿主进程)前的钩去掉。
4. ......

asp.net 密码回传后,不见 的解决办法

asp.net 密码回传后,不见 的解决办法
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                  & ......

asp.net中使用json前后台传值

使用input控件onclick传递json比较简单,
使用asp:Button 服务器控件onclick会回发刷新页面使json的值丢失。
在Handler1.ashx中使用静态变量存储当两个人同时操作的时候会出现问题,如果您有好的解决办法,希望能于大家分享。
以下代码大多来源于网上,在此感谢作者。
//前台
<script src="JS/json2.js" type="text ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号