Validators won't let me leave aspx form using web user controls!

  • Thread starter Thread starter Dot net work
  • Start date Start date
D

Dot net work

If I have got 2 web user controls on my aspx form, and one web user
control has got some validator controls on it, what I find is that if
I enter in some "bad data" in to some text boxes on the first web user
control, then click on a link button on the second web user control to
leave the aspx form, it won't let me - the validators run on the first
web user control and highlight the errors and won't let me leave until
I fix them. I'm trapped.
 
Validation controls work great for scenarios where you fill everything in
and submit (ie, simple forms). They get to be a pain in the butt when you
start dealing with complex logic and are best thrown out the window in those
cases. This may not be a popular statement, but it is factual.

You have a couple of choices.

1. Scrap the validation controls in this exercise.
2. Customize the validation to not validate on the second button push (could
be a coding nightmare, especially since you are dealing with controls in a
page).

I prefer the easy route, as the validation controls are meant to make your
life easier, not harder.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
The validators have an enabled property. You can use client side javascript
hooked up to each user controls button to disable the validators on the
oposite control.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Actually, I just found another workaround:

For the buttons and link buttons on the other web user control that
needs to override any validators on the first web user control, set
the CausesValidation property of these controls to false.

-dnw.
 
Back
Top