AngularJS 读取checkbox值

2024-11-07 14:18:42
推荐回答(2个)
回答1:

protected void Page_Load(object sender, EventArgs e)
{
CheckBox chk = new CheckBox();
chk.Text = "testall"; // 这里可以换成数据库的内容
chk.CheckedChanged += new EventHandler(chk_CheckedChanged);
chk.AutoPostBack = true;
Page.Form.Controls.Add(chk);

for (int i = 0; i < 10; i++)
{
CheckBox chk2 = new CheckBox();
chk2.Text = "test" + i.ToString(); // 这里可以换成数据库的内容
chk2.Checked = (i % 3 == 0); // 这里可以换成数据库的内容
Page.Form.Controls.Add(chk2);
}

}

void chk_CheckedChanged(object sender, EventArgs e)
{
CheckBox all = sender as CheckBox;
foreach(Control ctl in Page.Form.Controls)
{
if (ctl is CheckBox)
{
CheckBox chk = ctl as CheckBox;
chk.Checked = all.Checked;
}
}
}

回答2:

ng-true-value