我使用带有 runat="server" 的 htmlgenericcontrol 创建了一些 div、标签和复选框。这些动态创建的 div 被添加到在设计时创建的主 div 中。现在,我想在页面加载时使用 c# 访问动态创建的 div 内部的复选框。我使用 c# 创建的动态 div 看起来像这样 -
<div id='firstdiv'>
<div id='seconddiv'>
<label id='lbl' >
<input type="checkbox" id="chk" value="check" runat="server">
<div id='thirddiv'></div>
</label>
</div></div>
我尝试了以下选项,但没有一个有效 -
HtmlGenericControl chkfirstdiv = HtmlGenericControl)maindiv.FindControl(strchkfirstdiv) as HtmlGenericControl;
HtmlGenericControl chkfirstdiv1 = HtmlGenericControl)FindControl(strchkfirstdiv) as HtmlGenericControl;
LiteralControl literalControl = LiteralControl)maindiv.FindControl(strchkfirstdiv);
任何人都可以帮助访问动态 div 中的动态复选框吗?