E
Eric Maia
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:
CourseUserControl.ascx - select or enter a course
SessionUserControl.ascx - select or enter a course session
CourseDetails.aspx - a form which contains just CourseUserControl
CourseSessionDetails.aspx - a form which contains just
SessionUserControl
TrainingRequestDetails.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 (CausesValidation=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 SessionUserControl 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
separately in two other forms. The structure is essentially this:
CourseUserControl.ascx - select or enter a course
SessionUserControl.ascx - select or enter a course session
CourseDetails.aspx - a form which contains just CourseUserControl
CourseSessionDetails.aspx - a form which contains just
SessionUserControl
TrainingRequestDetails.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 (CausesValidation=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 SessionUserControl 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