ASP.NETÖзÀÖ¹Ò³Ãæ¶à´ÎÌá½»µÄ´úÂëʵÏÖ
´Ë´¦ÌṩµÄ´úÂëÓÃÀ´ÊµÏÖµ±asp.netÒ³ÃæÖеÄij¸ö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
Ïà¹ØÎĵµ£º
ÒýÓÃusing System.Web.UI.HtmlControls;
ǰ̨µÄ<table id="mytab" border="1" runat="server" class="t1" width="600">
......
ÕâÀïÖ÷Ҫ̸̸ApplicationÀàÖеÄʼþ
ÓÉǰһƪÎÄÕ¿ÉÒÔÖªµÀ£¬Ò»µ©³öÏÖÁËHttpContextÀàµÄÒ»¸öʵÀý£¬HttpRuntimeÀà¾Í»á½¨Á¢Ò»¸öASP.NETÓ¦ÓóÌÐò¶ÔÏóÀ´Íê³É¸ÃÇëÇó¡£Ò»¸öÓ¦ÓóÌÐò°üÀ¨HttpApplicationÀàµÄÒ»¸öʵÀý¡£HttpApplicationÊÇÒ»¸öglobal.asaxÅÉÉúµÄ¶ÔÏ󣬴¦ÀíËùÓб»´«µÝ¸øij¸öÐéÎļþ¼ÐµÃHttpÇëÇó¡£Ò»¸öÕýÔÚ ......
½ñÌìÒª×öºÃÒ»µãµÄµÇ½¿ò½á¹û¾ÍÏë×ö¸öÈ«¾ÖµÄÅжÏÊÇ·ñÓû§ËùÒÔÕÒÁËÒ»ÏÂÎÄÕÂ
ÕâÀïÖ¸µÄµ¥µã£¬·ºÖ¸ÔÚWEB·þÎñ¶Ë£¬Ò»¸öÕË»§Í¬Ò»Ê±¿ÌÖ»ÄÜ´æÔÚÒ»¸öƱ¾Ý£¡
´ó¼Ò¿ª·¢ÖпÉÄܶ¼Åöµ½µÄÒ»¸öÎÊÌ⣬Ôõôʹͬһ¸öÓû§£¬ÔÚͬһʱ¼äÄÚÖ»ÔÊÐíµÇ¼һ´Î¡£
ºÜ¶àÈ˶¼»áÏëµ½ÔÚÊý¾Ý¿âÖÐÓÃÒ»¸ö±êʶ×ֶΣ¬µÇ¼½øÈ¥ÖÃ1,Í˳öÖÃ0,µÇ¼ʱÅжÏÕâ¸ö×ֶΣ¬Èç¹ ......
Request¶ÔÏó¹¦ÄÜÊÇ´Ó¿Í»§¶ËµÃµ½Êý¾Ý£¬³£ÓõÄÈýÖÖÈ¡µÃÊý¾ÝµÄ·½·¨ÊÇ£ºRequest.Form¡¢Request.QueryString£¬Request¡£ÆäµÚÈýÖÖÊÇÇ°Á½ÖÖµÄÒ»¸öËõд£¬¿ÉÒÔÈ¡´úÇ°Á½ÖÖÇé¿ö¡£¶øÇ°Á½ÖÖÖ÷Òª¶ÔÓ¦µÄFormÌύʱµÄÁ½ÖÖ²»Í¬µÄÌá½»·½·¨£º·Ö±ðÊÇPost·½·¨ºÍGet·½·¨¡£
Request ¶ÔÏóµÄÊôÐԺͷ½·¨± ......
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);
......