CustomValidators without ServerValidate event

Discussion in 'ASP .Net' started by headware, Mar 9, 2005.

  1. headware

    headware Guest

    Lately, I've been using the CustomValidator control without the
    ServerValidate event handler. For instance, if I'm importing a file and
    there is an IOException thrown, I report back to the user that there
    was a problem by setting the IsValid property of a CustomValidator to
    false and returning.

    The real reason I do it this way is so that the error message will be
    displayed in the ValidationSummary control at the top of the page.
    Handling the ServerValidate event of the CustomValidator doesn't really
    make sense, because there's nothing to really validate, I just want to
    display the message in the ValidationSummary.

    I seem to be reading that this isn't a good idea. It appears to be
    working fine, and I was wondering if there is a problem with doing this
    that I'm not seeing.

    Thanks,
    Dave
    headware, Mar 9, 2005
    #1
    1. Advertising

  2. headware

    Peter Blum Guest

    I don't know if it will break in a future ASP.NET 2.0 version. But the
    validation framework doesn't care much how IsValid is set. It's OnPreRender
    method detects IsValid is false and displays the error message. Nothing more
    to it.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "headware" <> wrote in message
    news:...
    > Lately, I've been using the CustomValidator control without the
    > ServerValidate event handler. For instance, if I'm importing a file and
    > there is an IOException thrown, I report back to the user that there
    > was a problem by setting the IsValid property of a CustomValidator to
    > false and returning.
    >
    > The real reason I do it this way is so that the error message will be
    > displayed in the ValidationSummary control at the top of the page.
    > Handling the ServerValidate event of the CustomValidator doesn't really
    > make sense, because there's nothing to really validate, I just want to
    > display the message in the ValidationSummary.
    >
    > I seem to be reading that this isn't a good idea. It appears to be
    > working fine, and I was wondering if there is a problem with doing this
    > that I'm not seeing.
    >
    > Thanks,
    > Dave
    >
    Peter Blum, Mar 9, 2005
    #2
    1. Advertising

  3. headware

    headware Guest

    Thanks for the reply. Let's say for a second that this did break in
    ASP.NET 2.0. How would you achieve the same effect? As far as I know
    you can't dynamically add error messages to a ValidationSummary
    control. I guess you could use a separate Label for each error or make
    your own custom control to display error messages the way you want.
    However, I don't much like either of those options. Does anyone else
    have any other suggestions?

    Dave
    headware, Mar 9, 2005
    #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. Tiësto

    2 CustomValidators in a Page ?

    Tiësto, Nov 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    960
    Steven Cheng[MSFT]
    Nov 13, 2004
  2. =?Utf-8?B?RGF2ZQ==?=

    attaching an event to ServerValidate

    =?Utf-8?B?RGF2ZQ==?=, May 15, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    394
    =?Utf-8?B?S2VpdGg=?=
    May 15, 2007
  3. Aamir Ghanchi
    Replies:
    1
    Views:
    481
    Aamir Ghanchi
    Oct 2, 2007
  4. Andy B
    Replies:
    0
    Views:
    976
    Andy B
    Jan 23, 2009
  5. Andy B.
    Replies:
    0
    Views:
    762
    Andy B.
    Feb 20, 2009
Loading...

Share This Page