I have a RadioButtonList in asp.net. I am trying to do a simple thing i.e. to display or hide a div on changing the radio buttons from the list.But the event OnSelectedIndexChanged is not firing. I am not getting the reason. This is the code
<asp:RadioButtonList ID="CityStateZip" runat="server" ForeColor="#333300" AutoPostBack="true" RepeatDirection="Horizontal" Width="274px" CausesValidation="true" ValidationGroup="SchoolSearchGroup" OnSelectedIndexChanged="CityStateZip_SelectedIndexChanged">
<asp:ListItem Value="1" Text="City and State" />
<asp:ListItem Value="2" Text="Zip Code" />
</asp:RadioButtonList>
<div id="zipcodediv" runat="server" visible="false" style="margin-left:75px">
code.........
</div>
<div id="citystatediv" runat="server" style="margin-left:75px; width: 708px;">
code........
</div>
Code behind
protected void CityStateZip_SelectedIndexChanged(Object sender,EventArgs e)
{
if (CityStateZip.SelectedValue == "1")
{
zipcodediv.Visible = false;
citystatediv.Visible = true;
}
if (CityStateZip.SelectedValue == "2")
{
citystatediv.Visible = false;
zipcodediv.Visible = true;
}
}