Reputation: 4721
I want to access aHTML control
on server side, but while adding runat= server
, it is giving me error as
'chkA1<%# (Container.RecordIndex) %>' is not a valid identifier.
Here is my html
<input type="checkbox" runat="server" id="chkA1<%# (Container.RecordIndex)%>" name="chkAC1" style="width: 17px;
height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" />
When I remove runat=server
it works properly.
Why it is not working with runat=server
. Any suggestion
UPDATE
The Id's are changing accordingly of the checkboxes. Here is the code which I have written
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);
}
}
Upvotes: 2
Views: 608
Reputation: 32693
The ID is going to be a strongly typed identifier in C#. Therefore the ID can't change and it can't contain invalid characters.
The simple solution is to just remove that from your id attribute.
<input type="checkbox" runat="server" id="chkA1" name="chkAC1" style="width: 17px; height: 17px;" value="<%# (Container.RecordIndex)%>" onclick="AppoveCheckA(this)" />
Upvotes: 1