2010-01-18 29 views
5

更新:DROPDOWNLIST Page_ClientValidate后不回传()

我刚才已经找到了解决办法。下面的函数作品(除去其他部分):

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

但我不知道为什么,当我添加了其他部分不工作。

问:

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

function confirmSubmit() { 

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

     return false; 
    } 
} 

如果Page_ClientValidate(“组1”)返回false,下拉列表不会导致回传后,我首先选择的项目,只有当我选择下拉列表第二次出现回发。

有什么问题?

+1

您的验证规则是说该网页无效,并导致回发停止......这是他们应该做的。你可以发布你的验证器的标记吗? Group1中的一个人说它没有处于有效状态。 – 2010-01-18 04:46:29

+0

我找到了解决方案。 – Billy 2010-01-18 04:56:28

回答

0

我刚刚找到解决方案。下面的函数作品(除去其他部分):

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

Page_ClientValidate之后被调用时,变量Page_BlockSubmit被设置为true,这阻止自动过帐回来。 Page_BlockSubmit在第二次点击后重置为false,因为我仍然不完全理解的原因。我正在寻找更多,但我有一个解决方案,我在枪下,所以我滚动它...

只需在代码块中添加下面的代码,如果页面无效。

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;  
}