protected void Page_Load(object sender, EventArgs e)
{
CheckBoxNew();
if (!IsPostBack)
{
}
}
public void CheckBoxNew()
{
CheckBoxList cl = new CheckBoxList();
cl.ID = "cbl";
for (int i = 0; i < 5; i++)
{
ListItem checkBox = new ListItem();
checkBox.Text = "cb" + i;
cl.Items.Add(checkBox);
}
this.Panel1.Controls.Add(cl);
}
protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList ckf = (CheckBoxList)Panel1.FindControl("cbl");
Response.Write("<script>alert('" + ckf.Items[0].Text +"')</script>");
}