如果在radiobuttonlist控件中选择“选择日期”,我该如何显示日历控件和文本框控件?
<asp:RadioButtonList ID="rbl_immediate_date_view_2" CssClass="gp-contact-us-radiolist" runat="server">
<asp:ListItem>Immediate</asp:ListItem>
<asp:ListItem>Select date</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="calendar_view_2" TargetControlID="txtStartDate" PopupButtonID="rbl_immediate_date_view_2" runat="server" />
答案 0 :(得分:0)
这就是我要做的事情:
在我的标记中:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<asp:RadioButtonList ID="rbl_immediate_date_view_2"
CssClass="gp-contact-us-radiolist" runat="server"
onselectedindexchanged="rbl_immediate_date_view_2_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem>Immediate</asp:ListItem>
<asp:ListItem>Select date</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txtStartDate" runat="server" Visible="false"></asp:TextBox>
<asp:CalendarExtender ID="calendar_view_2" TargetControlID="txtStartDate" PopupButtonID="rbl_immediate_date_view_2" runat="server" />
</div>
现在在我的代码背后:
protected void rbl_immediate_date_view_2_SelectedIndexChanged(object sender, EventArgs e)
{
txtStartDate.Visible = rbl_immediate_date_view_2.SelectedValue == "Select date";
}