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

D

Darrel

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.
 
S

Sergey Poberezovskiy

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.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top