472,119 Members | 992 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

ClientSide Validation (solution to bypass "Refresh" in JavaScript)

Hello,

Currently I am using a large input form on a website that is based on
ASP and JavaScript.

Depending on the values that are filled in by the user the forms does a
refresh and makes other input fields available to fill in. I use the
JavaScript OnChange function (=clientside) that creates a querystring
and does a refresh of the page. It works fine.

Some of the users are complaining that on slow connections this refresh
can take very long and other users find this refresh in general not a
friendly solution. And... I agree with them.

Now I am trying to migrate this website to ASP.NET and was looking for
a solution to do what I want to do: Make form fields available/visable
in the same form based on the values filled in in other fields of the
same form without the refresh.

This is want I have found:
http://www.dotnetjunkies.com/quickst...validator2.src

But is this the way to do it? Can it also be ServerSide? I am sure that
I am not the only person in the world trying to do this. Thanks for
your advice. Please note that I am a beginner in ASP.NET.

I can not post the form because it an secured extranet page.

Thanks!

Nov 19 '05 #1
1 3144
When working with an ASP.NET web form, expect that when you submit, it will
post back to the same page. Your page will be structured with some code to
handle various "events". The two most common are:
- Page_Load. This method is used to setup general values on the page. It is
called every time the page is generated. For example, if you fill in a
DropDownList from a database, do it here when the page is first loaded (the
property Page.IsPostBack is false).
- "Post back event handlers" - These are methods you link to buttons and
other controls that submit the page. They fire only on post back after
Page_Load. You put your code that processes the post back. For example, in
the Button, set the Click event to your method. Then use your Click method
to save the page.
Inside the post back event handlers is where Validation goes. First, you add
the various web controls called "Validators" supplied with ASP.NET to the
web form. Attach them to the fields they evaluate. By design, they will
first attempt to validate on the client-side. But not all browsers are
supported or javascript can be disabled. So eventually the page is posted
back and you should assume the page is still not validated. So you test
Page.IsValid is true in that Click post back event method before saving. If
you find it to be false, just exit the Click event method and the same page
will be redraw, but this time, each validator with an error will be
displayed.

I encourage you to read this article: www.aspalliance.com/699 as you learn
about ASP.NET validators.
You should also consider a better validation system since Microsoft's is
very limited and causes you to write much custom code and develop hacks. I
make one called Professional Validation And More
(http://www.peterblum.com/vam/home.aspx).

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

"IkBenHet" <ik********@hotmail.com> wrote in message
news:11********************@g14g2000cwa.googlegrou ps.com...
Hello,

Currently I am using a large input form on a website that is based on
ASP and JavaScript.

Depending on the values that are filled in by the user the forms does a
refresh and makes other input fields available to fill in. I use the
JavaScript OnChange function (=clientside) that creates a querystring
and does a refresh of the page. It works fine.

Some of the users are complaining that on slow connections this refresh
can take very long and other users find this refresh in general not a
friendly solution. And... I agree with them.

Now I am trying to migrate this website to ASP.NET and was looking for
a solution to do what I want to do: Make form fields available/visable
in the same form based on the values filled in in other fields of the
same form without the refresh.

This is want I have found:
http://www.dotnetjunkies.com/quickst...validator2.src

But is this the way to do it? Can it also be ServerSide? I am sure that
I am not the only person in the world trying to do this. Thanks for
your advice. Please note that I am a beginner in ASP.NET.

I can not post the form because it an secured extranet page.

Thanks!

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Marcia Gulesian | last post: by
3 posts views Thread by George Durzi | last post: by
5 posts views Thread by chortler | last post: by
4 posts views Thread by Oren | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.