How can I add javascript client code while developing ASP.NET controls inside VS2005?

Discussion in 'ASP .Net Web Controls' started by Savvoulidis Iordanis, Jan 31, 2007.

  1. I want to create a checkbox that when clicked, selects/deselects all items
    in a list box, on the client side (no round trip)
    What kind of code should I add (and where in the asp.net web control) ?
    Savvoulidis Iordanis, Jan 31, 2007
    #1
    1. Advertising

  2. Re: How can I add javascript client code while developing ASP.NET controls inside VS2005?

    On Jan 31, 3:48 pm, "Savvoulidis Iordanis" <>
    wrote:
    > I want to create a checkbox that when clicked, selects/deselects all items
    > in a list box, on the client side (no round trip)
    > What kind of code should I add (and where in the asp.net web control) ?


    First of all EVERYBODY that is SERIOUS about JavaScript should deeply
    consider prototype.js
    (Google for it)
    Now assuming you have prototype.js file included in your page:

    var x = $('idOfMyCheckBox'); // often in "RenderContent" of your
    WebControl "string.Format("$('{0}');", ClientID)

    Element.observe(x, 'click', function(){
    $A(myListBoxElement.childNodes).each(function(idx){
    idx.selected = true;
    });
    });


    And off you go! :)
    To do this WITHOUT prototype.js would mean you're writing 10-20 times
    as many lines of code if you are serious about being browser
    compatible...

    ..t

    --
    http://ajaxwidgets.com
    Free ASP.NET Ajax Widgets NOW!
    Thomas Hansen, Feb 1, 2007
    #2
    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.

Share This Page