ASP.NET中防止页面多次提交的代码实现
此处提供的代码用来实现当asp.net页面中的某个Button被点击后disable掉该页面中所有的Button,从而防止提交延时导致的多次提交。基于之前的onceclickbutton脚本.
//ASP.NET中防止页面多次提交的代码:javascript< script language=”javascript”> < !– function disableOtherSubmit() {
var obj = event.srcElement;
var objs = document.getElementsByTagName(’INPUT’);
for(var i=0; i< objs.length; i++)
{
if(objs[i].type.toLowerCase() == ’submit’)
{
objs[i].disabled = true;
}
}
} //–> < /script>//ASP.NET中防止页面多次提交的代码:asp.netpublic class PreventMultiClick : System.Web.UI.Page {
protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.LinkButton LinkButton1; protected System.Web.UI.WebControls.Button Button3; private void Page_Load(object sender, System.EventArgs e)
{
this.GetPostBackEventReference(this.Button3);
//保证 __doPostBack(eventTarget, eventArgument) 正确注册 if(!IsPostBack)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(”if (typeof(Page_ClientValidate) == ‘function’)
{
if (Page_ClientValidate() == false)
{
return false;
}
}”); //保证验证函数的执行 sb.Append(”if(window.confirm(’are you sure?’)==false) return false; “);
//自定义客户端脚本 sb.Append(”disableOtherSubmit(); “);
// disable所有submit按钮 sb.Append(this.GetPostBackEventReference(this.Button3));
//用__doPostBack来提交,保证按钮的服务器端click事件执行 sb.Append(”; “);
Button3.Attributes.Add(”onclick”,sb.ToString());
}
} #region Web Form Designer generated code override protected void OnInit(EventArgs e)
{
// // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent();
base.OnInit(e);
}
/// < summary> /// Required method for Designer support – do not modify /// the contents of thi
相关文档:
先说我自己最笨的方法就是用Cookie!登陆时加一个userId在cookie里,然后删除文件重登时,如果session为空就取cookie去赋session!...如果大家不喜欢就用以下方法:
最简单的办法就是不要使用默认的方式也即
InProc(默认,进程内的会话状态):Session存储在IIS进程中(Web服务器内存)。如果使用的是Windows 20 ......
引用using System.Web.UI.HtmlControls;
前台的<table id="mytab" border="1" runat="server" class="t1" width="600">
......
ASP 是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术。 指 Active Server Pages(动态服务器页面) ,运行于 IIS 之中的程序 。
IIS
IIS 指 Internet Information Services(因特网信息服务)
IIS 是 Windows 2000 捆绑的免费组件
IIS同时也是 Windows NT ......
Private static readonly object ReflectionLock = new object();
Lock (ReflectionLock)
{
Type scriptManagerType =
Type.GetType(
"System.Web.UI.ScriptManager, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35",
false);
......
asp.net 基于vb。net编程语言 sql数据库
表1 ......