说我有下面的HTML,我想从一个C#的WebForms应用程序背后的代码生成。 如何创建复选框的标签吗?
HTML
<div class="col-lg-8 col-lg-offset-1">
<input id="combo" type="checkbox" value="false" />
<label for="combo" class="margin">Text Here</label>
</div>
后面的代码
private static HtmlGenericControl CreateHtmlInputCheckBoxControl(Filters filter)
{
HtmlGenericControl column = CreateColumn(filter);
column.Controls.Add(new HtmlInputCheckBox { Checked = false, Value = filter.Caption });
return column;
}
private static HtmlGenericControl CreateColumn(Filters filter, string additionalClasses = "")
{
HtmlGenericControl div = new HtmlGenericControl("div");
div.Attributes["class"] = string.Format("col-lg-{0} col-lg-offset-{1} {2}", filter.ColumnSpan, filter.ColumnOffset, additionalClasses);
return div;
}
在这种方法中增加对可能的标签或使用文字只有这样,才能做到这一点?