我想根据用户在组合框中的选择在UpdatePanel中隐藏文本框。它在UpdatePanel之外工作良好,但是当它放入UpdatePanel时,它停止工作,不再隐藏文本框。你能帮我解释一下吗?谢谢。仍然在UpdatePanel中显示文本框
我的编码是如下:
<script language="javascript" type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(BindControls);
$().ready(function() {
BindControls();
$("#<%= ddlType.ClientID %>").change();
});
function BindControls() {
$("#<%= ddlType.ClientID %>").change(function() {
ShowHideCalendars();
});
}
function ShowHideCalendars() {
$("#trDates").toggle($("#<%= ddlType.ClientID %>").val() == "T1");
}
</script>
<asp:UpdatePanel runat="server">
<contenttemplate>
<asp:DropDownList runat="server" id="ddlType" AutoPostBack="True"
onselectedindexchanged="ddlType_SelectedIndexChanged">
<asp:ListItem>T1</asp:ListItem>
<asp:ListItem>T2</asp:ListItem>
</asp:DropDownList>
<table>
<tr>
<td>Row 1</td>
</tr>
<tr id="trDates">
<td>From: <asp:TextBox ID="TextBox1" runat="server" CssClass="dtpicker"></asp:TextBox> To: <asp:TextBox ID="TextBox2" runat="server" CssClass="dtpicker"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Literal ID="ltStatus" runat="server" Text="You haven't selected."></asp:Literal></td>
</tr>
</table>
</contenttemplate>
</asp:UpdatePanel>