zoukankan      html  css  js  c++  java
  • ASP.NET防止重复提交

    同事写的,收录一下,方法如下:

        /// <summary>
        /// 防止重复提交
        /// </summary>
        /// <param name="imaButtons">按键集合</param>
        /// <param name="clientID">页面有JS验证的组件</param>
        public void RepeatSubmitCheckForRC( List<ImageButton> imaButtons)
        {
            foreach (ImageButton button in imaButtons)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("if (typeof(Page_ClientValidate) == 'function') { if (Page_ClientValidate() == false) { return false; }};");
                if (button.ID != "saveButton")
                {
                    sb.Append("if(!contentRequiredValidator()){return false};");//富文本编辑为空验证
                }
                sb.Append("this.disabled  = true;");
                sb.Append(this.Page.ClientScript.GetPostBackEventReference(button, ""));
                sb.Append(";");
                button.Attributes.Add("onclick", sb.ToString());
            }
        }

    调用方法的时候

            List<ImageButton> imaButtons = new List<ImageButton>();
            imaButtons.Add(sumbitButton);
            imaButtons.Add(saveButton);
            RepeatSubmitCheckForRC(imaButtons);

  • 相关阅读:
    ABP 异常
    Vmware中安装的Ubuntu不能全屏问题解决
    centos7.4 文件权限
    webpack 入门(1)
    webpack(2) 概念
    centos7.4 rpm命令
    centos7.4 which、whereis、locate的使用
    centos7.4 find命令
    centos7.4 lsof用法
    centos7.4 用户和组的管理
  • 原文地址:https://www.cnblogs.com/Hary/p/1387495.html
Copyright © 2011-2022 走看看