Trigger a Subset of Multiple Validators (Client-Side)

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.
 
M

Misbah Arefin

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
 
J

Jordan S.

Very good. Thank you! I'm using .NET 3.5, so the ValidationGroup property is
apparently what I'm needing.

-J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top