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

  • Thread starter Savvoulidis Iordanis
  • Start date
S

Savvoulidis Iordanis

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) ?
 
T

Thomas Hansen

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top