【发布时间】:2015-04-24 17:16:15
【问题描述】:
我在这里创建一个文本框及其对应的复选框。我需要的是...当我选中复选框时,我想启用文本框 注意:文本框最初是禁用的
for (int i = 0; i < count; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < 1; j++)
{
TableCell cell = new TableCell();
CheckBox chk = new CheckBox();
TextBox txt_ele = new TextBox();
txt_ele.ID = "elective" + i;
txt_ele.Enabled = false;
chk.ID = "chk_" + i.ToString();
chk.Text = "Has Elective Subjects";
chk.AutoPostBack = true;
cell.Controls.Add(chk);
cell.Controls.Add(txt_ele);
row.Cells.Add(cell);
chk.CheckedChanged += new System.EventHandler (chkDynamic_CheckedChanged);
}
table.Rows.Add(row);
this.NumberOfControls++;
}
page.Form.Controls.Add(table);
复选框勾选事件如下
protected void chkDynamic_CheckedChanged (object sender, EventArgs e)
{
CheckBox lb = (CheckBox)sender;
if (lb.Checked)
{
//how to do here
}
}
【问题讨论】:
标签: c# asp.net dynamic controls