asp.net如何在后台动态生成一个HtmlInputCheckBox控件显示在页面

2025-03-07 07:09:30
推荐回答(1个)
回答1:

.aspx.cs

using System.Web.UI.HtmlControls;

public partial class _Default: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HtmlInputCheckBox chk = new HtmlInputCheckBox();
chk.ID = "chk1";
chk.Value = "1";
chk.Checked = true;
Panel1.Controls.Add(chk);
}
}

.aspx