Update:
更新:
I have just found the solution. The following function works (remove the else part):
我刚刚找到了解决办法。以下功能工作(删除else部分):
function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
}
}
But I am wondering why it doesn't work when I add the else part.
但是我想知道为什么当我添加else部分时它不能工作。
Question:
问题:
I want to have a confirm dialog after user fills in all the data in the form. I set onclientclick="return confirmSubmit()" in the submit button.
在用户填写表单中的所有数据后,我希望有一个确认对话框。我在submit按钮中设置onclientclick=“return confirmSubmit()”。
function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
} else {
return false;
}
}
If Page_ClientValidate("Group1") returns false, the dropdownlist doesn't cause postback after I first select the item, and the postback only occurs when I select the dropdownlist second time.
如果Page_ClientValidate(“Group1”)返回false,那么在我第一次选择该项目后,dropdownlist不会导致回发,而回发只发生在我第二次选择dropdownlist时。
What's the problem?
是什么问题?
2 个解决方案
#1
11
After Page_ClientValidate is called, the variable Page_BlockSubmit gets set to true, which blocks the autopost back. Page_BlockSubmit was getting reset to false on the second click, for what reasons I still don't fully understand. I'm looking more into this, but I have a solution and I'm under the gun so I'm rolling with it....
在调用Page_ClientValidate之后,变量Page_BlockSubmit被设置为true,这将阻塞autopost。Page_BlockSubmit在第二次点击时被重置为false,原因是我仍然不能完全理解。我想更多,但是我有一个解决方案,我枪下我用它滚动....
Just add below code in the code block which executes if Page is not valid.
只要在代码块中添加以下代码,如果页面无效,代码块将执行这些代码。
Page_BlockSubmit = false;
e.g.
如。
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;
}
#2
0
I have just found the solution. The following function works (remove the else part):
我刚刚找到了解决办法。以下功能工作(删除else部分):
function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
}
}
#1
11
After Page_ClientValidate is called, the variable Page_BlockSubmit gets set to true, which blocks the autopost back. Page_BlockSubmit was getting reset to false on the second click, for what reasons I still don't fully understand. I'm looking more into this, but I have a solution and I'm under the gun so I'm rolling with it....
在调用Page_ClientValidate之后,变量Page_BlockSubmit被设置为true,这将阻塞autopost。Page_BlockSubmit在第二次点击时被重置为false,原因是我仍然不能完全理解。我想更多,但是我有一个解决方案,我枪下我用它滚动....
Just add below code in the code block which executes if Page is not valid.
只要在代码块中添加以下代码,如果页面无效,代码块将执行这些代码。
Page_BlockSubmit = false;
e.g.
如。
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;
}
#2
0
I have just found the solution. The following function works (remove the else part):
我刚刚找到了解决办法。以下功能工作(删除else部分):
function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
}
}