I have two UserControls I am using in a form. These are each also used
separately in two other forms. The structure is essentially this:
CourseUserContr ol.ascx - select or enter a course
SessionUserCont rol.ascx - select or enter a course session
CourseDetails.a spx - a form which contains just CourseUserContr ol
CourseSessionDe tails.aspx - a form which contains just
SessionUserCont rol
TrainingRequest Details.aspx - a form which includes both controls,
plus additional fields.
Each UserControl has an entry form with its own validation. When the
UserControl's submit button is clicked (CausesValidati on=true), the
event handler in the UserControl's cs file checks the IsValid
properties just of the validators that belong to the control (not
Page.IsValid).
This works fine on the pages that have a single UserControl - the
validators are checked, and any validation messages are displayed
properly.
When I try using the SessionUserCont rol to enter a new Session record
from the page that has both controls, the validators in the
UserControl are not called properly. The button event handler fires,
but the validators are always valid.
I even added code to specifically call each validator's Validate()
method directly in the event handler before I check whether the
pertinent validators are valid. It doesn't make any difference - the
validators always show IsValid=true when the control is called from
the page that has both controls.
Does anyone know why a change in the containing page would affect
validation behavior when the validation is encapsulated within the
UserControl?
Thanks - Eric