【发布时间】:2016-03-07 04:16:07
【问题描述】:
我想在服务器端访问 aHTML control,但是在添加 runat= server 时,它给了我错误
'chkA1' 不是有效标识符。
这是我的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。任何建议
更新
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);
}
}
【问题讨论】: