Mega Code Archive

 
Categories / ASP.Net / Asp Control
 

Read RadioButton selection (C#)

<%@ Page Language="c#" %> <script runat="server">     void Page_Load()     {       string msg = "You have selected the following items:<br />";       if (chkCities.Items[0].Selected)            msg += chkCities.Items[0].Text + "<br />";       if (chkCities.Items[1].Selected)            msg += chkCities.Items[1].Text + "<br />";       if (chkCities.Items[2].Selected)            msg += chkCities.Items[2].Text + "<br />";                  lblCities.Text = msg;     } </script> <html> <head>     <title>Check Box List Example</title> </head> <body>     <asp:Label id="lblCities" runat="server"></asp:Label>     <br />     <br />     Which city do you wish to look at hotels for?<br />     <br />     <form runat="server">         <asp:checkboxlist id="chkCities" runat="server">             <asp:listitem id="optMadrid" runat="server" value="Madrid" />             <asp:listitem id="optOslo" runat="server" value="Oslo" />             <asp:listitem id="optLisbon" runat="server" value="Lisbon" />         </asp:checkboxlist>         <br />         <br />         <input type="submit" value="Submit Query" />     </form> </body> </html>