Thursday 28 November 2013

how to make possible that one radio button will be selected at once in asp.net

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
   
    <form id="form1" runat="server">
    <div>
    <asp:RadioButton ID="RadioButton1"  GroupName="Gender" Text="Male" runat="server" /><br /><br />
    <asp:RadioButton ID="RadioButton2"  GroupName="Gender" Text="Female" runat="server" />
    <br />
    </div>
    </form>

</body>
</html>



when you debug this application if you click on one without specify the group name property of radio button then both will be selected at once... 

To remove this kind of problem specify the Group Name property of both the radio button ..

again debug this it will work like it should be.. 


Thank you

No comments:

Post a Comment