所以我已经基本上在头撞墙了一段时间了。对不起,如果我在这里抛出过多的代码,不知道解释它的更好方法。我有一个带有ItemTemplate的Repeater:jQuery对话框和直放站内部的复选框问题
<ItemTemplate>
<div id='FileFrame<%#Eval("Id")%>' class="view">
<userControl:ConfigFiles ID=<%#Eval("Id")%> runat="server" />
</div>
</ItemTemplate>
一些为div设置对话框的jQuery。
$(document).ready(function() {
$(".view").dialog({
autoOpen: false,
title: "Configuration Files",
buttons: {},
height: 600,
width: 800,
open: function (type, data) { $(this).parent().appendTo("form"); }
});
});
和一些更多jQuery打开对话框。
$("#FileFrame"+ConfigId).dialog('open');
现在用户控件具有一个“下载选中的复选框”按钮,沿其他中继器内的这里面一堆复选框。问题是,当我通过调试并单击按钮时,除非最初在aspx页面上设置了Checked =“true”,否则任何复选框都不会被读取为选中状态。
这里是代码背后的代码片段,它没有做我认为应该做的事情。
foreach (RepeaterItem item in FilesRepeater.Items)
{
CheckBox box = item.FindControl("DownloadFileCheckBox") as CheckBox;
if (box.Checked) //<-- always false unless I set it to true in aspx,
// then it's always true
{/*do work here*/}
}
有什么建议吗?
你在第一个'Eval()'上错过了一个关闭'%>' –
谢谢,我修复了一些我在打字时犯的一些小错误。所有的jQuery的作品,它打开对话框和一切。这只是一个问题,为什么复选框没有被“检查” –
检查Request.Form [box.UniqueID]的值是什么 - 取决于您何时检查值,CheckBox控件可能尚未更新在ASP.NET页面LifeCycle –