client side vs server side events for controls

Discussion in 'ASP .Net' started by Mong, May 6, 2004.

  1. Mong

    Mong Guest

    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
    Mong, May 6, 2004
    #1
    1. Advertising

  2. Mong

    WJ Guest

    "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
    WJ, May 6, 2004
    #2
    1. Advertising

  3. Mong

    DalePres Guest

    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/d...n-us/dnaspp/html/ASPNet-ForgottenControls.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" <> wrote in message
    news:...
    > 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
    DalePres, May 6, 2004
    #3
  4. Mong

    Rick Spiewak Guest

    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" <> wrote in message
    news:...
    > 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
    Rick Spiewak, May 6, 2004
    #4
  5. Mong

    Mong Guest

    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" <> wrote in message news:<eQOy3$>...
    > 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" <> wrote in message
    > news:...
    > > 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
    Mong, May 7, 2004
    #5
  6. 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" <> wrote in message
    news:...
    > 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" <> wrote in message

    news:<eQOy3$>...
    > > 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" <> wrote in message
    > > news:...
    > > > 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
    Kevin Spencer, May 7, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    14
    Views:
    4,071
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  2. msnews
    Replies:
    0
    Views:
    443
    msnews
    May 27, 2005
  3. Jake
    Replies:
    2
    Views:
    400
    Steve C. Orr [MVP, MCSD]
    Aug 17, 2005
  4. Stuart Whiteford
    Replies:
    2
    Views:
    735
    Stuart Whiteford
    Apr 25, 2006
  5. Zoe Hart
    Replies:
    1
    Views:
    354
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page