3

我有一個提交按鈕,使用微軟的ConfirmButton擴展器詢問「你確定嗎?」。但是,無論頁面是否通過客戶端驗證,它都會觸發。頁面驗證失敗時,如何禁用ASP.NET AJAX ConfirmButtonExtender?

<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,然後我得到這樣的警告:

驗證(ASP.Net):屬性 'ConfirmOnFormSubmit' 不是一個有效的 屬性元素 'ConfirmButtonExtender'。

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

+0

編輯:根據該網站它是有效的。嘗試更新到最新版本,或者忽略智能感知,只看看發佈時會發生什麼。 – craigmoliver 2009-01-28 00:39:38

+1

你是怎麼解決這個問題的,扎克? – Ram 2010-11-01 18:01:05

回答

3

確保ConfirmOnFormSubmit設置爲TRUE在ConfirmButtonExtender。

example site

ConfirmOnFormSubmit - True如果確認對話框應該等到之前的形式提交給顯示。這在ASP.NET驗證器正在使用時非常有用,只有在所有驗證器都通過後才能顯示確認。

編輯:根據該網站它是有效的。嘗試updating to the latest version,或者忽略智能感知,只看看發佈時會發生什麼。