Checking too see if client side validation functions will be sent to the browser

Discussion in 'ASP .Net' started by Darrel, Jul 9, 2004.

  1. Darrel

    Darrel Guest

    I am creating a server control that inherits from a command button.
    The problem is it needs to generate different client side script,
    depending on whether validators will get added to the page or not. On
    the server side, is there some way I can check to see if the asp.net
    page will be sending to the client the validation client side script
    or not. Currenly I have to loop through every control on the page to
    see if any of them is a validator. (A way that seems very inefficent.)
    Is there a better way? I want to able to say, if any client side
    validation will be done do this, otherwise do this.
    Darrel, Jul 9, 2004
    #1
    1. Advertising

  2. Darrel,

    you could check Page.Validators collection to see how many
    validators are on the page.

    And whether the validation code is appended to the output -
    I believe that validation script is generated only for
    IE - so checking the Request.Browser.Type.StartsWith("IE")
    will get you the rest.

    Hope this helps.


    >-----Original Message-----
    >I am creating a server control that inherits from a

    command button.
    >The problem is it needs to generate different client side

    script,
    >depending on whether validators will get added to the

    page or not. On
    >the server side, is there some way I can check to see if

    the asp.net
    >page will be sending to the client the validation client

    side script
    >or not. Currenly I have to loop through every control on

    the page to
    >see if any of them is a validator. (A way that seems very

    inefficent.)
    > Is there a better way? I want to able to say, if any

    client side
    >validation will be done do this, otherwise do this.
    >.
    >
    Sergey Poberezovskiy, Jul 10, 2004
    #2
    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. Libs
    Replies:
    0
    Views:
    1,492
  2. Matt
    Replies:
    14
    Views:
    4,096
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  3. =?Utf-8?B?dmlkeWE=?=
    Replies:
    1
    Views:
    750
    Kevin Spencer
    Jun 2, 2005
  4. Boss302
    Replies:
    0
    Views:
    1,042
    Boss302
    Nov 21, 2006
  5. Bogdan
    Replies:
    2
    Views:
    650
    Bogdan
    Jun 9, 2008
Loading...

Share This Page