<% -- Author wangaihui -- %> <% -- date 2008-8-10 -- %> <% @ page Language = "C #" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat = "server"> // select all or cancel protected void on the server side button#click (Object sender, eventargs e) {foreach (control C in this. form1.controls) {If (C is checkbox) {(checkbox) c ). checked =! (Checkbox) c ). checked ;}} if (this. button1.text = "select all") {This. button1.text = "cancel all";} else {This. button1.text = "all selected" ;}// the server obtains all selected names protected void button2_click (Object sender, eventargs e) {int COUNT = 0; foreach (control C in this. form1.controls) {If (C is checkbox) {If (C as checkbox ). checked) {count ++; this. textbox1.text + = C. id. tostring () + ";" ;}} this. textbox1.width = Count * 100 ;} </SCRIPT> <HTML xmlns = "http://www.w3.org/1999/xhtml">