473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

client side vs server side events for controls

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
5 2561
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Louden | last post by:
Personally, I am totally confused with the following control terms and usage and advantages of each one in ASP.NET web application. Here's what I know so far.. 1. HTML Client Control: understood...
1
by: john | last post by:
We have an asp.net page that we are mixing our C# code on both the code behind and in the .aspx page. We are using the code behind for a server side control that has post back events. but we are...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
5
by: Ben | last post by:
I want to enable/disable a text field cleint side based on a value in a dropdownlist, what is the 'best'/'standard' approach for handling this in ..net? I know i just just throw an on change...
2
by: Rea Peleg | last post by:
Hi all Is it possible to handle web controls events on client side??? I wrote a simple favascript function inside the <header> area of an aspx web form. This function is called on...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
5
by: Mike Labosh | last post by:
I have a WebForm that has, among other things, the following: ASP:TEXTBOX txtCorrectedName ASP:LISTBOX lstCorrectedNames The list box gets loaded with all the "correct" names of cities, and...
10
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The...
5
by: Vili | last post by:
Hi all I am having a problem here Is it possible to fire a server side function from client side? ie. I have a function on codebehind Sub DoSomething(o as object)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.