2
votes

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 the 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

3
Can you post the code for you 2 buttons and the validator? Also post which version of ASP.NET you are using. - Kelsey
Seconded, more information would help here. - Brian Scott
Have you set the validation group on the button, the validator, the textbox and the validation summary to be the same? - Michael Ciba
Can you post your validator was well so we can see that it wired up to the TextBox correctly and that the ValidationGroup is set as well. - Kelsey

3 Answers

0
votes

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.

0
votes

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.

0
votes

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.