1
在這個asp.net gridview控件中,checked屬性總是丟失。我需要通過jQuery訪問checked屬性在gridview中的asp.net複選框 - 檢查屬性丟失
Gridview source:
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelected" runat="server" class="chkSummarySelection" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
呈現爲:
<input type="checkbox" name="ctl00$ContentPlaceHolder1$gv$ctl02$SelectedCheckBox" id="ctl00_ContentPlaceHolder1_gv_ctl02_SelectedCheckBox">
沒有檢查屬性來訪問。 我試圖
$(".chkSummarySelection").click(function() {
var chk;
chk = $(this).prop("checked");
chk = $(this).attr("checked");
chk = $(this).is(":checked");
chk = $(this).attr("value");
chk = $(this).val();
chk = jQuery(this).is(':checked');
});
,但沒有什麼工作
一點題外話,請記住,一個'CheckBox',渲染時,不具有財產_checked_當它是未檢查。見[這可能相關的SO問題](http://stackoverflow.com/questions/4003303/input-type-checkbox-problem)。 您可以使用jQuery [:checked](http://api.jquery.com/checked-selector/)選擇器,就像您在示例中那樣。 – pleinolijf
我認爲這是我所追求的。 'checked'屬性根本就不存在,因此當我嘗試訪問它時(即使在它被選中後),那麼因爲該屬性從未存在過,所以我無法訪問它。有沒有辦法強制它創建'checked'屬性? –
當CheckBox被選中時,應該出現屬性_checked_,可能沒有任何值(它只會說沒有賦值的'checked')。你有沒有試過@ Amiram的建議呢? – pleinolijf