开发者

Asp.net regularexpressionvalidator fires even when CausesValidation="false"

开发者 https://www.devze.com 2022-12-24 07:54 出处:网络
I have a regularexpression validator which validates a valid email. I have two buttons on my form. Submit and undo.

I have a regularexpression validator which validates a valid email. I have two buttons on my form. Submit and undo.

On undo, we are reverting th开发者_Go百科e page state to default

submit has it validationgroup set while undo doesnot have any validationgroup and CausesValidation="false".

Now when i navigate to page and enter invalid emailaddress,i directly click undo. the validator fires and stops my page from posting.however if i press tab and navigate to other control and then click undo,the validator shows error message but posts back and furthur proessing is done.

This is very strange and i want the page to postback without any error message when i click undo.how to achieve it.

<tec:ThemedImageButton runat="server" ID="imgbtnSave" OnClick="imgbtnSave_Click"
     ValidationGroup="CustomerGroup"/>
<tec:ThemedImageButton runat="server" ID="imgbtnCancel" CausesValidation="false"
                                                OnClick="imgbtnCancel_Click" />

These are normal image buttons with added themes.CustomerGroup is the validation group for my textbox and regularexpressionvalidator


Are you possibly clicking the undo whilst your focus is still within the email textbox? If so, perhaps the issue is that the initial blur event of the textbox is firing which in turn is calling the email validator and preventing the click / submission.

The first thing to try is to make sure you can enter an invalid email address, move the focus onto a completely different area of the page and then press undo to determine if this is the cause.


Double check your settings. You might want to check the code behind to make sure you are not overwriting the control settings there. For example, in code, you might have the CausesValidation set to "True" or something like that.


Until you post more information you could do the following in your Undo button:

<asp:Button ID="btnUndo" runat="server" Text="Undo"
    OnClientClick="Page_ValidationActive = false;"
    OnClick="btnUndo_Click" />

I don't recommend this as it might solve your problem but really doesn't explain what is wired up incorrectly but the Page_ValidationActive = false; will disable all client validation on your page.

0

精彩评论

暂无评论...
验证码 换一张
取 消