Space Ghost

Space Ghost

  • NA
  • 45
  • 0

Listbox items and attributes

Mar 16 2010 9:20 AM
Hi all,

How do you set the 'onclick'/'onchange'/'click' event to a specific listbox so that when you click on one of the items in the listbox, you get for instance a "Hello" from the javascript alert("hello")? When I click on the listitem, nothing happens.

This is what I think I should do on the load of my main page. ddl1 is the listbox.


foreach (ListItem i in ddl1.Items)
{
i.Attributes.Add("onclick", "return listitems(this)");
}

Please please any help.


Thanks,


Answers (2)