user control set property of a parent web form?

J

jamesd

I have a user control that has some simple textboxes. The user control
is placed into a regular webform with a submit button on it.

When the submit button is clicked, the form is posted to the server.
The user control contains some code to SERVER SIDE validate one of the
textboxes.

IF the validation fails, i want the parent web form to know about it,
and display a message on the screen.

I know this is easy if I use client side validation, but it does not
seem to work for server side validation. Any suggestions?
 
C

Cowboy \(Gregory A. Beamer\)

Use delegates to cascade up to the parent form. Then, set a IsValid property
in the user control. On the parent form test the IsValid property. If not
valid, do not submit, else, submit the form values.

Overall, it is a "best practice" to have the form control the controls. You
CAN get away from this if it is the only control on the form. Else, expose
the properties and let the form pull values to submit. Always validate at
control level, else you end up with a major mess trying to validate multiple
user controls.

Hope this makes sense.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top