Do not manually validate insider your custom control. Always let the page
developer identify exactly when validation occurs.
1. Buttons automatically call the Page.Validate() method for you unless
their CausesValidation property is false. This happens in their OnClick
method after Page_Load is done an before calling your Click event method.
Page.Validate() will run your validators.
2. Sometimes a button should never validate, such as a Cancel button. Again
the user takes control by setting CausesValidation to false.
3. AutoPostBack never calls Page.Validate(). If the user elects to validate
on autopostback, they add a call to Page.Validate() in their own event
handler for that post back.
4. Users can also call the Validate() method on individual validators and
check their IsValid property to see the result. If you want to support this,
I recommend adding a method to your custom control called Validate() that
fires the Validate() methods on each validator. Also include an IsValid
property which returns true if all validators are valid.
--- Peter Blum
Creator of "Professional Validation And More" at
"Martin" <martin_no_spammartinz.co.nz> wrote in message
> I have an asp.net page with two composite controls on it as well as a
> button in the asp.net page AND a single dropdown box on the page that has
> its autopostback property set to true so that it posts back when ever the
> selection is changed.
> what i would like to do is when the button (in the aspx page NOT on any of
> the composite controls) is clicked and causes a postback to validate both
> composite controls - however i want no validation to occur if the dropdown
> box causes the postback.
> I have implemented IPostBackDataHandler in both controls and have verified
> that they are both notified when the button in the page is clicked.
> so i figured that i could validate each control in its respective
> so basically i need to work out how to know exactly which element on the
> page caused a postback.
> I therefore have two questions.
> 1. Is my method of validating each composite control on a page in it's
> respective "RaisePostDataChangedEvent" the correct way of achieving such a
> feet or do I need to re-think my stagegy, if so any advice is welcome..
> 2. How do I tell exactly tell which element on a page caused a postback.
> I appreciate any feedback or pointers to article of interest.
> thanks in advance.