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

client side vs server side events for controls

P: n/a
Hi,

I have a webform with various asp controls on it such as textboxes and
dropdownlists. I'm fairly new to asp.net coming from VB6 and am
wondering when it's best to use client side events and when it's best
to use server side events.

For example, if a textbox is to contain a date I want to validate the
date when that textbox loses the focus. If the date is not valid I
make visible a label next to the textbox telling the user it's
invalid. At the moment I'm doing this in the server side TextChanged
event for the textbox and have noticed this is fairly slow.I'm
thinking this kind of thing should be done on the client side - would
that be correct?

If so, how do I do this?

Also, is there a reference out there which shows all the available
client side events these asp (web form) controls have and how to
implement them?

I'm assuming you would code these using Javascript. Are there any
alternatives or is that the standard? Should VBScript be left alone as
it seems to me it's being fazed out now that asp.net can use native VB
on the server side? Or is that a mute point as my understanding is
client side and server side are two seperate entities?

So many questions!

Thanks for any replies.

Regards,

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


P: n/a
Web Server Controls don't have client side events. HTML Server Controls
(HTML Controls set to runat=server) have onclick and onload events.

Here's a great article on HTML Server Controls and when you might want to
use them: (watch for line breaks...make sure you get the whole thing.)

http://msdn.microsoft.com/library/de...enControls.asp

Along with what's in that article, one big reason I consider when choosing
Web Server controls or HTML Server controls is the target audience. In an
intranet situation, the postback of web server controls isn't such a big
issue, but on the internet, with dial-up users, postback can be a real pain
in the axle and using HTML Server controls lets you do more on the client
side and then postback less often.

Hope that helps.

Dale
"Mong" <mo*********@yahoo.com.au> wrote in message
news:47**************************@posting.google.c om...
Hi,

I have a webform with various asp controls on it such as textboxes and
dropdownlists. I'm fairly new to asp.net coming from VB6 and am
wondering when it's best to use client side events and when it's best
to use server side events.

For example, if a textbox is to contain a date I want to validate the
date when that textbox loses the focus. If the date is not valid I
make visible a label next to the textbox telling the user it's
invalid. At the moment I'm doing this in the server side TextChanged
event for the textbox and have noticed this is fairly slow.I'm
thinking this kind of thing should be done on the client side - would
that be correct?

If so, how do I do this?

Also, is there a reference out there which shows all the available
client side events these asp (web form) controls have and how to
implement them?

I'm assuming you would code these using Javascript. Are there any
alternatives or is that the standard? Should VBScript be left alone as
it seems to me it's being fazed out now that asp.net can use native VB
on the server side? Or is that a mute point as my understanding is
client side and server side are two seperate entities?

So many questions!

Thanks for any replies.

Regards,

Mong

Nov 18 '05 #2

P: n/a
WJ
"Mong"
when it's best to use client side events
Whenever you do not depend on server for data validation.
and when it's best to use server side events.
Whenever you depend on server to retrieve data such as verifying if certain
pieces of data match with those entered on the form by the client.

For example, if a textbox is to contain a date I want to validate the
date when that textbox loses the focus. If the date is not valid I
make visible a label next to the textbox telling the user it's
invalid. At the moment I'm doing this in the server side TextChanged
event for the textbox and have noticed this is fairly slow.
This is good. Nothing wrong with it. Slowness depends on bandwidth and your
server (hardware) capacity. If you have a form that has 50 fields on it, it
is run on T1 and your server has about 1GB RAM and its clock speed is approx
600MHZ or above, it is fairly quick. I say this for no more than 50
concurrent hits (conservative).
I'm thinking this kind of thing should be done on the client side - would
that be correct?

It is a perfect solution, this saves you a trip back and forth between CS.
However, some clients donot like to enable Java script or any client side
scripts. Judge it yourself if you should or should not enforce certain
things on clients. For Intranet, this is easier because you know who your
users are.
If so, how do I do this?

Use Java script or VB script (Very Bad). I prefer JS. If you use
MS/FrontPage, you can enable field validation easily. FP will create JS or
VB scripts for you. Or you can hand code it yourself. For a sample, please
visit this site: http://javascript.internet.com/forms/validate-date.html
Also, is there a reference out there which shows all the available
client side events these asp (web form) controls have and how to
implement them?
Plenty at http://www.google.com, once there, enter a search term of your
choice such as "how to code event in javascript"

I'm assuming you would code these using Javascript.?
Yes, it is the best
Should VBScript be left alone as...
VBS=Very Bad Sh....
So many questions!


Be expert on 1 thing only. Donot try too many, let someone else has a chance
to make a few $ too. Your life is short ! Reserve some for deep-sea fishing
later... and never give everything to your boss entirely !

Happy .Netting

John
Nov 18 '05 #3

P: n/a
You can use the validation controls to do client-side validation, they
generate their own javascript to do so. You should then check the
page.isvalid property on postback, just to be sure.

"Mong" <mo*********@yahoo.com.au> wrote in message
news:47**************************@posting.google.c om...
Hi,

I have a webform with various asp controls on it such as textboxes and
dropdownlists. I'm fairly new to asp.net coming from VB6 and am
wondering when it's best to use client side events and when it's best
to use server side events.

For example, if a textbox is to contain a date I want to validate the
date when that textbox loses the focus. If the date is not valid I
make visible a label next to the textbox telling the user it's
invalid. At the moment I'm doing this in the server side TextChanged
event for the textbox and have noticed this is fairly slow.I'm
thinking this kind of thing should be done on the client side - would
that be correct?

If so, how do I do this?

Also, is there a reference out there which shows all the available
client side events these asp (web form) controls have and how to
implement them?

I'm assuming you would code these using Javascript. Are there any
alternatives or is that the standard? Should VBScript be left alone as
it seems to me it's being fazed out now that asp.net can use native VB
on the server side? Or is that a mute point as my understanding is
client side and server side are two seperate entities?

So many questions!

Thanks for any replies.

Regards,

Mong

Nov 18 '05 #4

P: n/a
Thanks very much for your replies, very helpful!

Just one further question regarding VBScript - everyone keeps
condemning the use of it compared to JavaScript but no one really
explains why, so why is it so bad?
"Rick Spiewak" <ri*********@mindspring.com> wrote in message news:<eQ*************@TK2MSFTNGP11.phx.gbl>...
You can use the validation controls to do client-side validation, they
generate their own javascript to do so. You should then check the
page.isvalid property on postback, just to be sure.

"Mong" <mo*********@yahoo.com.au> wrote in message
news:47**************************@posting.google.c om...
Hi,

I have a webform with various asp controls on it such as textboxes and
dropdownlists. I'm fairly new to asp.net coming from VB6 and am
wondering when it's best to use client side events and when it's best
to use server side events.

For example, if a textbox is to contain a date I want to validate the
date when that textbox loses the focus. If the date is not valid I
make visible a label next to the textbox telling the user it's
invalid. At the moment I'm doing this in the server side TextChanged
event for the textbox and have noticed this is fairly slow.I'm
thinking this kind of thing should be done on the client side - would
that be correct?

If so, how do I do this?

Also, is there a reference out there which shows all the available
client side events these asp (web form) controls have and how to
implement them?

I'm assuming you would code these using Javascript. Are there any
alternatives or is that the standard? Should VBScript be left alone as
it seems to me it's being fazed out now that asp.net can use native VB
on the server side? Or is that a mute point as my understanding is
client side and server side are two seperate entities?

So many questions!

Thanks for any replies.

Regards,

Mong

Nov 18 '05 #5

P: n/a
Client-side VBScript is not supported by all browsers. JavaScript is.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mong" <mo*********@yahoo.com.au> wrote in message
news:47*************************@posting.google.co m...
Thanks very much for your replies, very helpful!

Just one further question regarding VBScript - everyone keeps
condemning the use of it compared to JavaScript but no one really
explains why, so why is it so bad?
"Rick Spiewak" <ri*********@mindspring.com> wrote in message

news:<eQ*************@TK2MSFTNGP11.phx.gbl>...
You can use the validation controls to do client-side validation, they
generate their own javascript to do so. You should then check the
page.isvalid property on postback, just to be sure.

"Mong" <mo*********@yahoo.com.au> wrote in message
news:47**************************@posting.google.c om...
Hi,

I have a webform with various asp controls on it such as textboxes and
dropdownlists. I'm fairly new to asp.net coming from VB6 and am
wondering when it's best to use client side events and when it's best
to use server side events.

For example, if a textbox is to contain a date I want to validate the
date when that textbox loses the focus. If the date is not valid I
make visible a label next to the textbox telling the user it's
invalid. At the moment I'm doing this in the server side TextChanged
event for the textbox and have noticed this is fairly slow.I'm
thinking this kind of thing should be done on the client side - would
that be correct?

If so, how do I do this?

Also, is there a reference out there which shows all the available
client side events these asp (web form) controls have and how to
implement them?

I'm assuming you would code these using Javascript. Are there any
alternatives or is that the standard? Should VBScript be left alone as
it seems to me it's being fazed out now that asp.net can use native VB
on the server side? Or is that a mute point as my understanding is
client side and server side are two seperate entities?

So many questions!

Thanks for any replies.

Regards,

Mong

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.