0
我有一個asp.net formview內的下拉列表,當我試圖用jquery獲取ddl的選定值時,我得到一個空引用異常。當嘗試爲DropDownList獲取選定值時的空引用異常FormView
的jQuery:
if ($('#<%=fvSubscriber.FindControl("ddlTransactionType").ClientID %>').val() == "Disconnect")
{
alert("test");
}
標記:
<asp:DropDownList ID="ddlTransactionType" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlTransactionType_SelectedIndexChanged" TabIndex="1">
<asp:ListItem Selected="True" Value="Choose">Choose Type...</asp:ListItem>
<asp:ListItem Value="Enroll">Enroll</asp:ListItem>
<asp:ListItem Value="Disconnect">Disconnect</asp:ListItem>
<%-- DISABLED transaction types during data entry phase
<asp:ListItem Value="Transfer">Transfer</asp:ListItem>
<asp:ListItem Value="Update">Update</asp:ListItem>
<asp:ListItem Value="DeEnrollDeceased">De-enroll Deceased</asp:ListItem>
<asp:ListItem Value="DeEnrollLeaving">De-enroll Leaving</asp:ListItem>
<asp:ListItem Value="DeEnrollFailedRecertification">De-enroll Failed Recertification</asp:ListItem>
<asp:ListItem Value="DeEnrollNonUsage">De-enroll NonUsage</asp:ListItem> --%>
</asp:DropDownList>
的Null Reference Exception
是<%=fvSubscriber.FindControl("ddlTransactionType").ClientID %>
嘗試加載頁面時發生異常。所以我讀這個的方式是它確實找到了控件,但沒有找到選定的值。我在這裏錯過了什麼?
沒有例外!!謝謝,你能解釋一下這是幹什麼的,爲什麼我的findcontrol語法在這種情況下是無效的? – Jason