user control set property of a parent web form?

Discussion in 'ASP .Net' started by jamesd, Aug 14, 2006.

  1. jamesd

    jamesd Guest

    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?
     
    jamesd, Aug 14, 2006
    #1
    1. Advertising

  2. 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:...
    >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?
    >
     
    Cowboy \(Gregory A. Beamer\), Aug 15, 2006
    #2
    1. Advertising

  3. jamesd

    jamesd Guest

    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:...
    > >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?
    > >
     
    jamesd, Aug 15, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    4,444
  2. Reny J Joseph Thuthikattu
    Replies:
    1
    Views:
    562
    =?Utf-8?B?UHJha2FzaC5ORVQ=?=
    Dec 30, 2004
  3. Roy
    Replies:
    1
    Views:
    874
    Scott Allen
    Feb 10, 2005
  4. DC Gringo
    Replies:
    1
    Views:
    5,076
    Karl Seguin
    Apr 26, 2005
  5. David Webb
    Replies:
    6
    Views:
    196
    David Webb
    Dec 30, 2004
Loading...

Share This Page