using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; //包含demo namespace demo5 { public partial class baohan2 : System.Web.UI.Page { protected void CheckBoxList1_DataBound(object sender, EventArgs e) { int n = CheckBoxList1.Items.Count; for (int i = 0; i < n; i++) { CheckBoxList1.Items[i].Text = CheckBoxList1.Items[i].Text; } } protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) { int n = CheckBoxList1.Items.Count; for (int i = 0; i < n; i++) { if(CheckBoxList1.Items[i].Selected ) { string txt= CheckBoxList1.Items[i].Text; string t = txt.Replace ("你好","谢谢"); Response.Write(t); } } } protected void Button1_Click(object sender, EventArgs e) { //如果当前排列是垂直排列 if (CheckBoxList1.RepeatDirection == RepeatDirection.Vertical) { Button1.Text = "垂直排列"; CheckBoxList1.RepeatDirection = RepeatDirection.Horizontal; } else { Button1.Text = "给我水平排列"; CheckBoxList1.RepeatDirection = RepeatDirection.Vertical; } } } }
感受:
这个可以用于评教里面,排列可以横排,可以竖排,选项,选中之后会有反应。
时间: 2024-10-08 03:03:04