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

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

Cowboy \(Gregory A. Beamer\) [MVP]

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!
************************************************
 
S

S. Justin Gengo

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
 
D

Dot net work

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.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top