我正在尝试检查:已选中复选框状态但在调试代码时未注册为已选中状态。从我在其他stackoverflow文章中读到的内容,以下代码应该可以工作。除非有我遗失的东西?
C#:
protected void MarkAsRead(object sender, EventArgs e)
{
foreach (RepeaterItem aItem in rptInbox.Items)
{
HtmlInputCheckBox chkDisplayTitle = (HtmlInputCheckBox)aItem
.FindControl("chkDisplayTitle");
if (chkDisplayTitle.Checked)
{
var messageid = chkDisplayTitle.Value;
}
}
}
HTML:
<input id="chkDisplayTitle" type="checkbox" class="i-checks" runat="server"
value='<%# Eval("MessageId")%>' />
中继器:
<asp:Repeater ID="rptInbox" runat="server">
<ItemTemplate>
<tr class="<%# Eval("MessageRead")%>">
<td class="check-mail">
<input id="chkDisplayTitle" type="checkbox" runat="server" value='<%# Eval("MessageId")%>' />
</td>
<td class="mail-ontact"><a href="mail_detail.aspx?id=<%# Eval("MessageId")%>"><%# Eval("FromUser")%></a></td>
<td class="mail-subject"><a href="mail_detail.aspx?id=<%# Eval("MessageId")%>"><%# Eval("Subject")%></a></td>
<td class=""><%# Eval("Attachment")%></td>
<td class="text-right mail-date"><%# Eval("MessageDateTime")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>