0

如何仅在单选按钮列表控件中选择“选择日期”时显示日历控件和文本框控件?

 <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" />
4

1 回答 1

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";
}
于 2013-08-04T16:41:50.930 回答