abatishchev
abatishchev

Reputation: 100308

Is it possible to avoid control validation after clicking one button and don't after clicking another?

I have a UserControl used for getting an exchange rate amount from user (bank manager) he prefer to be used by an account operation. Exchange rate can be loaded from central bank web service but just as a tip - final value is chosen by user.

It contains one asp:TextBox box and two asp:LinkButton - Get (exchange rate) and Approve (client request).

The text box value must be checked for existence (by RequiredFieldValidator) and correctness (by RegularExpressionValidator and CompareValidator) before approving.

So the problem is - if user clicks on Get button, validation also is invoked and failed. How to disable it for Get button but enable for Approve button?

Upvotes: 0

Views: 1384

Answers (1)

Canavar
Canavar

Reputation: 48088

Use CausesValidation property of the Button or LinkButton controls to enable / disable validation for validation controls.

<asp:Button ID="btnGetRate" Text="Get Rate"
     CausesValidation="False" OnClick="btnGetRate_Click" runat="server"/>

Upvotes: 6

Related Questions