Oh boy, sorry Pete but that solution isn't going to do it. If you want to
disable a validator on the server side, just set its Enabled property to
false. Don't remove it from Page.Validators. (Really!)
VB Programmer, it is *VERY* common to desire a validator that is disabled
based on other values on the page. It's too bad that Microsoft's validators
don't have this capability. You have several choices:
1. Write a custom validator that applies your rules. This is only a good
direction if you intend to keep client-side validation (because of #2
below). So you will have to figure out the javascript and DHTML logic in
your custom validator.
2. Abandon client-side validation. Do this:
- Set CausesValidation=false
- In your Click event method, call the Validate() method on individual
validators that apply.
3. Switch your validation system to something that actually handles this
case. "Professional Validation And More"
(
http://www.peterblum.com/vam/home.aspx) is a replacement to Microsoft's
validators. All of its 22 validators support the following features and
provide client-side validation on many more browsers than IE and IE/Mac
which Microsoft supports:
- Use the Enabler property on a validator to setup a rule that determines if
the validator should fire. For example, the rule can test if a textbox has
text. That textbox can be in the GOLD MEMBER section. The validator is in
the BRONZE MEMBER section.
- Use "validation groups". Have separate Submit buttons for each group of
fields. The button and validators all have a property called "Group". Assign
the same name to the button and its validators in the Group property. The
button will only validate those in its group.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Peter Morris [Air Software Ltd]" <pe**********@guess.co.uk> wrote in
message news:%2******************@TK2MSFTNGP12.phx.gbl...
Set "CausesValidation" to false on your button.
Then do something like this
Page.Validators.Remove(ThatValidator as IValidator)
Then call Page.Validate() before checking Page.IsValid
--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com
My blog
http://blogs.slcdug.org/petermorris/