Trigger a Subset of Multiple Validators (Client-Side)

  • Thread starter Thread starter Jordan S.
  • Start date Start date
J

Jordan S.

I'm experimenting with dynamically inserting custom composite Web server
controls onto a page. For testing purposes I have two custom composite Web
server controls that each have a couple of TextBox controls and a "submit"
button, as well as required field validators for each of the textboxes.

What I'm finding is that when both of these Web server controls appearon the
page, clicking on the "submit" button of either of the controls causes
validation of *both* Web server controls' TextBox controls.

Just wondering:
1. Is this by design?... that ASP.NET would cause all client-side validators
to run whenever any Submit button is clicked?

2. Is there any way to trigger the client-side validators for ONLY the
custom Web Server control to which the validators are explicitly tied?

I understand that we can set a .CausesValidation property to be False - but
that setting applies for all time. What I'd like is some way to have
client-side validation happen for one set of controls when one Submit button
is clicked; but when a different Submit button is clicked validate a
completely different set of controls.

Thanks.
 
Jordan S. said:
I'm experimenting with dynamically inserting custom composite Web server
controls onto a page. For testing purposes I have two custom composite Web
server controls that each have a couple of TextBox controls and a "submit"
button, as well as required field validators for each of the textboxes.

What I'm finding is that when both of these Web server controls appearon
the page, clicking on the "submit" button of either of the controls causes
validation of *both* Web server controls' TextBox controls.

Just wondering:
1. Is this by design?... that ASP.NET would cause all client-side
validators to run whenever any Submit button is clicked?

if you are using .NET 1.1 then yes this is by design but you can work around
it by using a CustomValidator
2. Is there any way to trigger the client-side validators for ONLY the
custom Web Server control to which the validators are explicitly tied?

in .NET 2.0 you set the ValidationGroup property of the validator controls
and the submit button. when the submit button is clicked only the validator
controls in the same ValidationGroup will be checked
 
Very good. Thank you! I'm using .NET 3.5, so the ValidationGroup property is
apparently what I'm needing.

-J
 
Back
Top