页面提交延迟造成客户端多次点击提交
对于这个有什么好的方法呢
我按照以前的方法在OnClientClick中写“this.disabled=true;this.form.submit();”
但不行,提交是提交了,那些事件都没有触发
该怎么搞啊

解决方案 »

  1.   

    ajax的UpdateProgress +一个半透明的层.
      

  2.   

    1.执行完重新跳回此页面
    2.网上有SubmitOncePage类的源码编译成一个单独的dll,引用可以了
    namespace myControl
    {
        /**//// <summary>
        /// 名称:SubmitOncePage 
        /// 父类:System.Web.UI.Page
        /// 描述:解决浏览器刷新造成的数据重复提交问题的page扩展类。
        /// 示例:    if (!this.IsRefreshed)
        ///            {
        ///                //具体代码
        ///            }
        ///    原创:丛兴滋(cncxz)    E-mail:[email protected]
        /// </summary>
        public class SubmitOncePage:System.Web.UI.Page
        {
            private string _strSessionKey;
            private string _hiddenfieldName;
            private string _strLastViewstate;
            public SubmitOncePage()
            {
                _hiddenfieldName="__LastVIEWSTATE_SessionKey";
                _strSessionKey=System.Guid.NewGuid().ToString();
                _strLastViewstate=string.Empty;        }        public bool IsRefreshed
            {
                get
                {
                    string str1 = this.Request.Form["__VIEWSTATE"];
                    _strLastViewstate = str1;
                    string str2 = this.Session[GetSessinKey()] as string;            
                    bool flag1 = (str1 != null)&&(str2!=null)&&(str1==str2);
                    return flag1;
                }
            }        protected override void Render(System.Web.UI.HtmlTextWriter writer)
            {
                string str=GetSessinKey();
                this.Session[str] = _strLastViewstate;
                this.RegisterHiddenField(_hiddenfieldName,str);
                base.Render (writer);
            }        
            private string GetSessinKey()
            {
                string str = this.Request.Form[_hiddenfieldName];
                return (str==null)?_strSessionKey:str;
            }
        }}
     private void Button1_Click(object sender, System.EventArgs e)
            {
                int i=int.Parse(Label1.Text)+1;
                Label1.Text = i.ToString();
                if (!this.IsRefreshed) 
                {
                    WriteFile("a.txt", i.ToString()); 
                }
                WriteFile("b.txt", i.ToString());  
            
                
            }        private void WriteFile(string strFileName,string strContent)
            {
                string str = this.Server.MapPath(strFileName);       
                System.IO.StreamWriter sw = System.IO.File.AppendText(str);
                sw.WriteLine(strContent);
                sw.Flush();
                sw.Close();  
            }
      

  3.   

    this.disabled=true执行了之后,按钮就不可用了,提交事件肯定不执行了将真正的提交按钮隐藏,显示给用户的按钮调用提交按钮的click()事件提交,然后把显示按钮隐藏办法比较笨,但是可行
      

  4.   

    to 1f 我暂时还不想用ajax
    to 2f 你的应该是解决提交后的刷新,我都是用redirect本页来解决的,谢谢
    to 3f 我试试看,不知有没有更简单快捷的方式呢,最好是一个按钮解决啦,不然就很麻烦
      

  5.   

    提交后使按钮所在的表格行或div为不可见,然后显示一个动画(滚动条等)提示处理中,请稍候什么的
      

  6.   

    Button1.Attributes.Add("onclick", "this.value='正在提交中,请等待……';this.disabled=true;" + this.GetPostBackEventReference(Button1));