加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – Dropdownlist在Page_ClientValidate()之后不回发

发布时间:2020-12-16 03:29:19 所属栏目:asp.Net 来源:网络整理
导读:更新: 我刚刚找到了解决方案.以下功能有效(删除else部分): function confirmSubmit() { if (Page_ClientValidate("Group1")) { return window.confirm("Are you sure to submit the form?"); } } 但是我想知道为什么当我添加else部分时它不起作用. 题: 用
更新:

我刚刚找到了解决方案.以下功能有效(删除else部分):

function confirmSubmit() {
     if (Page_ClientValidate("Group1")) {
         return window.confirm("Are you sure to submit the form?");
     } 
 }

但是我想知道为什么当我添加else部分时它不起作用.

题:

用户填写表单中的所有数据后,我想要一个确认对话框.
我在提交按钮中设置了onclientclick =“return confirmSubmit()”.

function confirmSubmit() {

     if (Page_ClientValidate("Group1")) {
         return window.confirm("Are you sure to submit the form?");
     } else {

         return false;
     }
 }

如果Page_ClientValidate(“Group1”)返回false,则在我第一次选择项目后,下拉列表不会导致回发,并且只有在我第二次选择下拉列表时才会发生回发.

有什么问题?

解决方法

调用Page_ClientValidate后,变量Page_BlockSubmit将设置为true,从而阻止autopost返回.由于我仍然不完全理解的原因,Page_BlockSubmit在第二次点击时被重置为false.我正在寻找更多,但我有一个解决方案,我在枪下,所以我正在努力….

如果Page无效,只需在代码块中添加以下代码即可执行.

Page_BlockSubmit = false;

例如

function ValidatePage() 
{
    flag = true;
    if (typeof (Page_ClientValidate) == 'function') 
    {
        Page_ClientValidate();
    }

    if (!Page_IsValid) 
    {
        alert('All the * marked fields are mandatory.');
        flag = false;
        Page_BlockSubmit = false;
    }
    else 
    {
        flag = confirm('Are you sure you have filled the form completely? Click OK to confirm or CANCEL to edit this form.');    
    }
    return flag;       
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读