Use 'Switch' to read Radio Button Choice (C#) : RadioButton « Asp Control « ASP.Net






Use 'Switch' to read Radio Button Choice (C#)

<script language="C#" runat="server">
void Page_Load()
{
  if (Page.IsPostBack) {
    switch(Destination.SelectedItem.Value) 
    {
      case "B":
        Message.Text = "You selected B";
        break; 
      case "C":
        Message.Text = "You selected C";
        break; 
      case "D": 
        Message.Text = "Your selected D";
        break; 
      default:
        Message.Text = "you did not select a destination";
        break; 
    }
  }
}
</script>

<html>
<head></head>
<body>
  <form runat="server">
  Select your choice of destination:
  <br><br>
  <asp:radiobuttonlist id="Destination" runat="server">
    <asp:listitem>B</asp:listitem>
    <asp:listitem>C</asp:listitem>
    <asp:listitem>D</asp:listitem>
  </asp:radiobuttonlist>
  <br><br>
  <input type="submit" value="Submit Choice">
  <br><br>
  <asp:label id="Message" runat="server"/>
</form>
</body>
</html>

           
       








Related examples in the same category

1.On asp:radiobutton selection state changed (VB.net)
2.asp:radiobutton: group name (VB.net)
3.asp:radiobutton: text align (VB.net)
4.Set asp:radiobutton checked (VB.net)
5.Font-Size, Font-Bold, Font-Name for radio button (VB.net)
6.GroupName for asp:radiobutton (VB.net)
7.Check a asp:radiobutton (VB.net)
8.Radio button auto post back (C#)
9.Watch TextBox, CheckBox and radiobutton auto post back action (C#)
10.Get selected RadioButton (C#)
11.Read RadioButton selection (C#)