Search code examples
htmlasp.netcssradio-buttonradiobuttonlist

Checking a radio button within asp.net application


I have this code:

<div class="divpere" >
   <div class="divfille1" ><label>CIVILITE:</label></div>
      <div class="divfille2" >
         <input type="radio" ID="mademoiselle" runat="server" >Mademoiselle</input>
         <input type="radio" ID="madame" runat="server">Madame</input>
         <input type="radio" ID="monsieur" runat="server">Monsieur</input>
      </div>
   </div>

It's a labale and a list of radio buttons, when i try to check one of this radio button, it still not checked!!

  • What is the reason of this?
  • How can i fix my snippet?

Solution

  • Demo Fiddle

     <div class="divpere" >
            <div class="divfille1" ><label>CIVILITE:</label></div>
            <div class="divfille2" >
             <input name="samename" type="radio" id="mademoiselle" runat="server" /><label for="mademoiselle"> Mademoiselle</label>
             <input name="samename" type="radio" id="madame" runat="server"/><label for="madame">Madame</label>
             <input name="samename" type="radio" id="monsieur" runat="server"/><label for="monsieur">Monsieur</label>
            </div>
     </div>
    

    You should mention the name attribute for your radio buttons and Don't forget to mention the same name values for all three radio buttons...