Using VS 2008, I have a Repeater control with nested elements and want to select one of them (the checkboxes) with jquery.
<asp:Repeater runat="server" ID="storesRep" DataSourceID="storeSqlDataSource" OnItemDataBound="StoresRep_ItemDataBound">
<ItemTemplate>
<table style="padding:0px">
<tr>
<td style="width:200px"><asp:Label ID="infoLbl" runat="server">Choose stores for upload:</asp:Label> </td>
<td style="width:110px"><asp:Label ID="storeLbl" runat="server" Text='<%# Bind("Name") %>'></asp:Label> </td>
<td><asp:CheckBox runat="server" ID="storeCheck" CssClass="storeCheck" /></td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
<table runat="server" id="footerTbl" visible="false" style="padding:0px">
<tr>
<td style="width:200px"><asp:Label ID="infoLbl" runat="server">Choose stores for upload:</asp:Label> </td>
<td><asp:Label ID="lblEmptyData" Text="No Stores found." runat="server" ForeColor="GrayText"></asp:Label></td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Here is my script
$('#<%= uploadBtn.ClientID %>').click(
function() {
//check if store was chosen from list
var storeChecked = false;
$('#<%= storeCheck.ClientID %>').each(function() {
if ($(this).attr('checked'))
storeChecked = true;
});
if (storeChecked == false) {
alert("Upload is only possible if a store has been chosen from list.");
return false;
}
I get the compiler error "storeCheck is not a known name in the current context".
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…