Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Onclick event to Checkboxlist control

Status
Not open for further replies.

jlitondo

MIS
Jun 27, 2000
175
US
is there a way to add an onclick event to a checkboxlist control?

 
you can add an onclick js attribute to the client code.
Code:
MyDropDownList.Attributes.Add("onclick","javascript:DoSomething(this);");
as for server events the default option is the SelectedIndexCanged event.
what are you trying to accomplish with a click event that a selected index change event could not do?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
i have a checkboxlist and a checkbox control. When the user selects the checkbox, it unchecks all selected items in the checkboxlist and alternatively if any item on the checkboxlist is selected, then it unchecks checkbox. I can accomplish this in code but this also requires that the controls postback each time. The page has several of these controls so my main goal really is to accomplish the process without posting back the page each time a control is clicked. I'll try your solution, I have a javascript function that runs if added to the checkbox through the html but the asp checkboxlist doesn't have this attribute.

 
well i got this to work now. What i ended up doing was placing each checkbox in its own anchor tag, and then making the javascript function call through the anchor tag's onclick event.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top