Ioana Marcu
Ioana Marcu

Reputation: 551

How to activate validators only on button click

I'm using Ajax Control Toolkit validators on an ASP.NET page, whose values can be saved by clicking a Submit button. The page can have distinct sections depending on two radio buttons (so the radio buttons have Autopostback set to true). My problem is that when I click the radio buttons to switch sections (so on postback) the validators are activated and appear as red. I don't want this behavior. I want the validation to be done only when the user clicks Submit.

EDIT: The cause was found. Somewhere inside the page, a control was performing Page.Validate().

Upvotes: 2

Views: 1535

Answers (2)

RL89
RL89

Reputation: 1916

Make radio button Causes validation to false.

Example

<asp:radiobutton runat="server" CausesValidation="False">
</asp:radiobutton>

Hope this helps

Upvotes: 2

Gaurav Agrawal
Gaurav Agrawal

Reputation: 4431

use validationgroup property of Ajax Control Toolkit validators and Submit button.

Upvotes: 1

Related Questions