![](/img/trans.png)
[英]Required field validator not working when OnClientClick is added in the button
[英]How to turn required field validator off when selecting cancel button
我的頁面上有一個必需的字段驗證器,但我也想使用一個“取消”按鈕,該按鈕將使用response.redirect(“ default.aspx”)將用戶帶回到菜單頁面。
問題是單擊“取消”按鈕時,字段驗證器會不斷觸發。 您如何關閉此功能,以便用戶可以返回菜單頁面?
只需將CausesValidation="false"
添加到您的按鈕定義中,它將不會引發任何驗證器:
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.