2
我想在服务器端访问HTML control
,但同时加入runat= server
,它给我的错误作为添加RUNAT服务器HTML控件给错误
“chkA1 <%#(Container.RecordIndex)%> '不是有效的标识符。
这里是我的html
<input type="checkbox" runat="server" id="chkA1<%# (Container.RecordIndex)%>" name="chkAC1" style="width: 17px;
height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" />
当我删除runat=server
它工作正常。
为什么它不能与runat=server
一起使用。任何建议
UPDATE
ID用相应的复选框的变化。这里是我写的代码
var checkBoxID;
var status;
var arrA = [];
var arrB = [];
var rowIndex
function AppoveCheckA(chk) {
status = true;
checkBoxID = $(chk).attr("id");
funClientSelectAfter(status, checkBoxID);
}
function AppoveCheckB(chk) {
status = true;
checkBoxID = $(chk).attr("id");
funClientSelectAfter1(status, checkBoxID);
}
function funClientSelectAfter(status, checkBoxID) {
if (status && checkBoxID != null) {
var len = checkBoxID.length;
if (len >= 7) {
rowIndex = checkBoxID.substring(checkBoxID.length - 2, checkBoxID.length);
}
else {
rowIndex = checkBoxID.substring(checkBoxID.length - 1, checkBoxID.length);
}
for (var col = 1; col <= 4; col++) {
if (("chkA" + col + rowIndex) == checkBoxID) {
if (document.getElementById("chkA" + col + rowIndex).checked == true) {
$("#chkA" + col + rowIndex).attr("checked", true);
arrA[rowIndex] = col;
continue;
}
else
arrA[rowIndex] = 0
}
$("#chkA" + col + rowIndex).attr("checked", false);
}
document.getElementById("hidRateA").value = arrA.join();
// alert(document.getElementById("hidRateA").value);
}
}
'id's'正在改变,但在gridview中有很多行,id也相应地改变 – BNN
@coder将访问此输入的代码添加到您的问题中。 – mason
为此添加了代码。 – BNN