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

Client-Side Validation using ASP.NET

P: n/a
Hello Guys,

I am using the validation controls to validate my data.
But the problem is "The page is still being posted to
server".

I want to get rid of the round trips to server. Are there
any get arounds for this problem apart from the
traditional JavaScript?

I mean to say ... can we use validation controls at the
client-side ONLY and not at the server-side? I understand
that there is a ClientValidate which is costly as I have
to maintain similar code at the server too.

Thanks a bunch!

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Anonymous,

The point of client side validation is to save a trip to the server. But
client side validation isn't guaranteed to work becuase of the wide
assortment of computers and browsers.

The way .Net handles this is to use client side validation to rule out
unecessary trips to the server for clients and browsers that it will work
for.

The validation on the server side can then be skipped by using an if/then
such as:

If Page.IsValid Then
'---your code here
End If

..Net checks if the client side validation worked and if so skips the server
side validation.

If the client side validation didn't work then the server side validation
takes over.

Also, all .net validators check if input is valid both client side and
server side (if the client validation didn't work). This means that a round
trip to the server won't take place if the client side validators are able
to run.

I hope this helps.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hello Guys,

I am using the validation controls to validate my data.
But the problem is "The page is still being posted to
server".

I want to get rid of the round trips to server. Are there
any get arounds for this problem apart from the
traditional JavaScript?

I mean to say ... can we use validation controls at the
client-side ONLY and not at the server-side? I understand
that there is a ClientValidate which is costly as I have
to maintain similar code at the server too.

Thanks a bunch!

Nov 18 '05 #2

P: n/a
Jos
an*******@discussions.microsoft.com wrote:
Hello Guys,

I am using the validation controls to validate my data.
But the problem is "The page is still being posted to
server".
Do you mean that the client-side validation doesn't work?
Is this with all users?
What kind of validation controls did you use?
I want to get rid of the round trips to server. Are there
any get arounds for this problem apart from the
traditional JavaScript?

I mean to say ... can we use validation controls at the
client-side ONLY and not at the server-side? I understand
that there is a ClientValidate which is costly as I have
to maintain similar code at the server too.


Using client-side validation only is unsafe, because
malicious users have many ways to by-pass it.
Therefore, if safety is important, never trust the client-side
validation!

--

Jos
Nov 18 '05 #3

P: n/a
Dear Justin,

Thanks for your reply!

Let me explain you my concern in detail....

I have a login field which I am validating using
RequiredValidator control. Now when a user omits this
field, the ErrorMessage is displayed successfully with the
help of validator control, but the page is still being
posted back to the server.

As you said, if the validation is done successfully at the
client-side, server-side validation is skipped. But I want
to stop the postback completely if the user omits the
login field. Can this be done using ASP.NET?

Thanks in advance!
-----Original Message-----
Anonymous,

The point of client side validation is to save a trip to the server. Butclient side validation isn't guaranteed to work becuase of the wideassortment of computers and browsers.

The way .Net handles this is to use client side validation to rule outunecessary trips to the server for clients and browsers that it will workfor.

The validation on the server side can then be skipped by using an if/thensuch as:

If Page.IsValid Then
'---your code here
End If

..Net checks if the client side validation worked and if so skips the serverside validation.

If the client side validation didn't work then the server side validationtakes over.

Also, all .net validators check if input is valid both client side andserver side (if the client validation didn't work). This means that a roundtrip to the server won't take place if the client side validators are ableto run.

I hope this helps.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hello Guys,

I am using the validation controls to validate my data.
But the problem is "The page is still being posted to
server".

I want to get rid of the round trips to server. Are there any get arounds for this problem apart from the
traditional JavaScript?

I mean to say ... can we use validation controls at the
client-side ONLY and not at the server-side? I understand that there is a ClientValidate which is costly as I have
to maintain similar code at the server too.

Thanks a bunch!

.

Nov 18 '05 #4

P: n/a
Anonymous,

The behaviour you would like is what .Net already does.

What browser are you testing with? If a required field is omitted then the
page typically does not post back to the server, but that behaviour doesn't
work with all browsers.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
<an*******@discussions.microsoft.com> wrote in message
news:96****************************@phx.gbl...
Dear Justin,

Thanks for your reply!

Let me explain you my concern in detail....

I have a login field which I am validating using
RequiredValidator control. Now when a user omits this
field, the ErrorMessage is displayed successfully with the
help of validator control, but the page is still being
posted back to the server.

As you said, if the validation is done successfully at the
client-side, server-side validation is skipped. But I want
to stop the postback completely if the user omits the
login field. Can this be done using ASP.NET?

Thanks in advance!
-----Original Message-----
Anonymous,

The point of client side validation is to save a trip to

the server. But
client side validation isn't guaranteed to work becuase

of the wide
assortment of computers and browsers.

The way .Net handles this is to use client side

validation to rule out
unecessary trips to the server for clients and browsers

that it will work
for.

The validation on the server side can then be skipped by

using an if/then
such as:

If Page.IsValid Then
'---your code here
End If

..Net checks if the client side validation worked and if

so skips the server
side validation.

If the client side validation didn't work then the server

side validation
takes over.

Also, all .net validators check if input is valid both

client side and
server side (if the client validation didn't work). This

means that a round
trip to the server won't take place if the client side

validators are able
to run.

I hope this helps.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hello Guys,

I am using the validation controls to validate my data.
But the problem is "The page is still being posted to
server".

I want to get rid of the round trips to server. Are there any get arounds for this problem apart from the
traditional JavaScript?

I mean to say ... can we use validation controls at the
client-side ONLY and not at the server-side? I understand that there is a ClientValidate which is costly as I have
to maintain similar code at the server too.

Thanks a bunch!

.

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.