views:

275

answers:

2

I have a scenario where I'm using a newly added ValidationSummary control. The form that I am working on has multiple buttons (customer search, submit, etc). Is it possible to fire the ValidationSummary only when the user clicks the submit button, as opposed to the customer search button?

+1  A: 

On the Customer Search button, add "CausesValidation='False'"

Chris Shaffer
This was exactly what I was looking for.
proudgeekdad
+2  A: 

The best and most general way to do this is to assign a value to the ValidationGroup property for the summary and all the controls which are to be validated, as well as the submit button. Only controls with the same ValidationGroup are affected.

Using validation groups, you can have different parts of a page validate without affecting each other. This feature was introduced with ASP.NET 2.0 by popular demand.

Tor Haugen
Thanks for the tip! I have multiple instances of the same user control on this form. I overrode the ID property on the UC to set all the validation controls and ValidationSummary to have a ValidationGroup of the control's ID. Each control now has its own ValidationSummary and works beautifully.
proudgeekdad