Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > user control set property of a parent web form?

Reply
Thread Tools

user control set property of a parent web form?

 
 
jamesd
Guest
Posts: n/a
 
      08-14-2006
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?

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      08-15-2006
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!
*************************************************
"jamesd" <> wrote in message
news: ps.com...
>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?
>



 
Reply With Quote
 
 
 
 
jamesd
Guest
Posts: n/a
 
      08-15-2006
It does makes sense, but will it work for a server side validation
postback?




Cowboy (Gregory A. Beamer) wrote:
> 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!
> *************************************************
> "jamesd" <> wrote in message
> news: ps.com...
> >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?
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
Page load of the parent page called twice when a modal dialog is opened from a button click of the user control on the parent page Samy ASP .Net 2 08-15-2005 03:30 PM
set public property in another web user control DC Gringo ASP .Net 1 04-26-2005 02:24 AM
How do I set the property for a Web User Control properties from the parent form (VB) David Webb ASP .Net Web Controls 6 12-30-2004 09:21 PM
accessing the web user control's control from a web page and set a value from another web page Reny J Joseph Thuthikattu ASP .Net 1 12-30-2004 12:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57