I am looking for the best way to handle index changes selected in ASP.net RadioButtonList (C # code). I have 3 list items. For the first, I want it to display a hidden asp: textbox on the page, while the other 2 hid the text box.
//asp.net side <asp:RadioButtonList ID="_indicatorAckType" runat="server" RepeatDirection="Horizontal" enabled="true" OnSelectedIndexChanged="onAckTypeChanged"> <asp:ListItem Text="None" /> <asp:ListItem Text="SHOW" /> <asp:ListItem Text="HIDE" /> </asp:RadioButtonList> //code behind protected void onAckTypeChanged(object sender, EventArgs e) { if (_indicatorAckType.SelectedItem.Text == "SHOW") _myTextboxID.Visible = true; else _myTextboxID.Visible = false; }
At first I tried using onclick event handlers, but I was told that ListItem cannot use onclick events with switch elements. What am I doing wrong here? This does not cause any errors or has obvious problems. I tried to make onSelectedIndexChanged do nothing but show a text field, and this also does not work.
Any help is appreciated! Thanks to everyone.
Imreg
source share