Conditionally Show Hide Radio Buttons

Anonymous
2023-07-25T06:23:25.0566667+00:00
Capturemalefemale.JPG


Conditionally Show Hide Radio Buttons , The pregant , normal radio buttons should be shown only when Female is selected

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,330 questions
{count} votes

Accepted answer
  1. Lan Huang-MSFT 26,761 Reputation points Microsoft Vendor
    2023-07-25T09:08:05.17+00:00

    Hi @KALYANA ALLAM,

    First set Visible="false" to hide the "Normal/Pregnant" radio button, then use the OnCheckedChanged event in the Male/Female radio button and set postback: AutoPostBack="true".

    <asp:RadioButton ID="Male" runat="server"    Text  ="Male" GroupName="gender" AutoPostBack="true" OnCheckedChanged="Male_OnCheckedChanged" />
            <asp:RadioButton ID="Female" runat="server"   Text  ="Female" GroupName="gender" AutoPostBack="true" OnCheckedChanged="Female_OnCheckedChanged"  /> <br/>
            <asp:RadioButton ID="Nor" runat="server"    Text  ="Normal" GroupName="preg" Visible="false" />
            <asp:RadioButton ID="Preg" runat="server"   Text  ="Pregnant" GroupName="preg" Visible="false"  /> <br/>
    
     protected void Male_OnCheckedChanged(object sender, EventArgs e)
            {
                Nor.Visible = false;
                Preg.Visible = false;
            }
            protected void Female_OnCheckedChanged(object sender, EventArgs e)
            {
                Nor.Visible = true;
                Preg.Visible = true;    
            }
    

    enter image description here

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more