By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.