Client side validation in asp.net forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Has anyone any experience using client side validation with asp.net forms.

Specifically I'd like to know...

1. How do you attach client side code web controls (a button), like a
JavaScript 'onclick' event for example?
2. Any issues anyone has experienced using client side validation with
asp.net forms?

Thanks in advance

Simon Ames
 
All validator controls run on the client side unless scripting in the client
browser is switched off. Hence using validator controls will be equivalent
to writing "Onclick" event code on the client side.


Krishnan
 
Hi Simon,

Like you normally write a javascript and place it in regular place.
Only thing you have to do is.
for the button webcontrol add the following:
button.attribute.add("onClick","Javascript:return click();")
This has to be put in the page load so that this function is available when
the page is loaded.
i think this is what you want.
Anything else do reply.
ARvind.
 
Krishnan said:
All validator controls run on the client side unless scripting in the
client browser is switched off. Hence using validator controls will
be equivalent to writing "Onclick" event code on the client side.

Another condition is that the browser be IE.
ASP.NET client side validation doesn't work in Netscape.
 
The button controls always use the client-side onclick event themselves for
running the client-side validation. You cannot just use
Button1.Atttributes.Add("onclick", "[your code]")
Instead, set Button1.CausesValidation = false to prevent it from generating
that code. Then add your code. If you want the client-side validation to
continue, the script is available by calling
Page.GetPostBackClientReference. For example:
Button1.Atttributes.Add("onclick", "[your code]" +
Page.GetPostBackClientReference(Button1, ""))

There are many issues with using client-side validation. In fact, there are
many issues with validation in general. I publish a replacement to
Microsoft's validations because there are so many limitations. Use this link
to see all the problems I found: http://www.peterblum.com/vam/valmain.aspx.
Even if you don't want my product ("Professional Validation And More" -
http://www.peterblum.com/vam/home.aspx), this list will help you plan your
development efforts better.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top