views:

28

answers:

2

Hello guys,

I have a radiobutton list (With 2 rdb) and a check list (7 ckb). I would like the checkbox list appears only when the user selects the second radio button is checked.

I never used AJAX before.

My actual code (yes, they are inside a table):

<td>

                    <asp:Label ID="Label7" runat="server" Font-Bold="True">Frequency</asp:Label>
                    <table>
                        <tr>
                            <td>
                                <asp:RadioButtonList ID="rdbDaysList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="rdbDaysList_SelectedIndexChanged"
                                    RepeatColumns="2" CausesValidation="True">
                                    <asp:ListItem>Daily</asp:ListItem>
                                    <asp:ListItem>Weekly</asp:ListItem>
                                </asp:RadioButtonList>
                            </td>
                        </tr>
                        <tr>
                            <td class="style3">
                                <asp:CheckBoxList ID="ckbList" runat="server" Visible="false" RepeatColumns="5" RepeatDirection="Horizontal">
                                    <asp:ListItem>Monday</asp:ListItem>
                                    <asp:ListItem>Tuesday</asp:ListItem>
                                    <asp:ListItem>Wednesday</asp:ListItem>
                                    <asp:ListItem>Thursday</asp:ListItem>
                                    <asp:ListItem>Friday</asp:ListItem>
                                    <asp:ListItem>Saturday</asp:ListItem>
                                    <asp:ListItem>Sunday</asp:ListItem>
                                </asp:CheckBoxList>
                            </td>
                        </tr>
                    </table>
</td>

Thanks in advance!

+1  A: 

You'll need to surround the radion button and check box list with an UpdatePanel control. Then in the OnSelectIndexChanged event on the radio button control, set the Visible property of then check box list to true.

d4nt
It not worked. Should I trigger the updatepanel with the radiobutton in some way besides the event?
Pmdusso
If you set a break point in the SelectedIndexChanged event does it hit it? If not, there's a problem with the radio button not doing an auto postback. Otherwise the problem is the check box list is not being set to visible properly.
d4nt
Man, everything is in its place and still does not work. My page is inside a Master Page. This should interfere in some way?
Pmdusso
YES! I putted my ScriptManager in the master page and everuthing worked fine! Thanks for the inspiration!
Pmdusso
A: 

make sure the RadioButtonList autoPostback = true