编程语言
首页 > 编程语言> > 页面验证失败时,如何禁用ASP.NET AJAX ConfirmButtonExtender?

页面验证失败时,如何禁用ASP.NET AJAX ConfirmButtonExtender?

作者:互联网

我有一个使用Microsoft的ConfirmButton扩展程序的“提交”按钮,问“您确定吗?”.但是,无论页面是否通过客户端验证,它都会触发.

<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidatorTextBox1"
    runat="server"
    ControlToValidate="TextBox1"
    ErrorMessage="First name is required"
    Display="Dynamic" />
...
<asp:Button ID="Button1"
    runat="server"
    Text="Submit"
    CausesValidation="True" />
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtenderButton1"
    runat="server"
    TargetControlID="Button1"
    ConfirmText="Are you sure?" />
...
<asp:ValidationSummary id="ValidationSummary1"
    runat="server"
    ShowMessageBox="True" />

因此,如果用户将必填字段留空,然后单击“提交”按钮.她将看到两个消息框:

一个用于验证…

ValidationSummary ShowMessageBox http://img120.imageshack.us/img120/8305/validationzn6.gif

然后一个确认…

ConfirmButtonExtender http://img228.imageshack.us/img228/678/confirmationam3.gif

(注意:“确定”和“取消”都只是取消.)

如果验证失败,则显示确认没有任何意义.应该是其中之一.我怎样才能做到这一点?

更新:

如果我尝试使用ConfirmOnFormSubmit,则会收到以下警告:

Validation (ASP.Net): Attribute
‘ConfirmOnFormSubmit’ is not a valid
attribute of element
‘ConfirmButtonExtender’.

Validation (ASP.Net): Attribute ‘ConfirmOnFormSubmit’ is not a valid attribute of element ‘ConfirmButtonExtender’. http://img382.imageshack.us/img382/1391/confirmonformsubmitow3.gif

解决方法:

确保在ConfirmButtonExtender上将ConfirmOnFormSubmit设置为TRUE.

example site开始:

ConfirmOnFormSubmit-如果确认对话框应等到表单提交显示之前,则为True.当使用ASP.NET验证程序并且仅在所有验证程序通过后才显示确认时,此功能很有用.

编辑:根据该网站,它是有效的.尝试updating to the latest version或忽略智能感知,然后看看发布时会发生什么.

标签:validationsummary,asp-net-ajax,asp-net,javascript,confirmbutton
来源: https://codeday.me/bug/20191210/2103654.html