BRIEF EXPLANATION OF RADIO BUTTON CONTROL IN ASP.NET

RADIO BUTTON CONTROL IN ASP.NET


The radio button is an asp.net web server control. The radio button is used to allow the user to select a Radio button from a group of Radio buttons. In asp.net we usually use more than one Radio button and select only one Radio button at a time from all the Radio button controls. On the other hand, in checkbox control, we can check and uncheck multiple checkbox controls at once.


Example of RadioButton Control in ASP.Net


Let's take the example of an asp.net radio button to understand more about Radio button control.


ASP.Net has some important properties of radio button control: - Checked = true/false, indicating whether the radio button control is checked or unchecked.


The GroupName = GroupName property is used to create a group of radio buttons. If we assign the same value to more than one radio button, we can select only one radio button from that group of radio buttons.


HTML design code for asp.net web form: -


<body>

  <form id="form1" runat="server">

  <div>

  

    <table align="center" class="style1" style="border: thin solid #008080">

      <tr>

        <td class="style2" 

          style="text-align: center; border-bottom-style: solid; border-bottom-width: thin; border-bottom-color: #008080;">

          RadioButton Control in ASP.Net</td>

      </tr>

      <tr>

        <td style="text-align: center">

 

           

          </td>

      </tr>

      <tr>

        <td style="text-align: center">

          <asp:RadioButton ID="radiored" runat="server" Text="RED" GroupName="my" />

 

          <asp:RadioButton ID="radioblue" runat="server" Text="BLUE" GroupName="my" />

 

          <asp:RadioButton ID="radiogreen" runat="server" Text="GREEN" GroupName="my" 

            oncheckedchanged="radiogreen_CheckedChanged" />

        </td>

      </tr>

      <tr>

        <td style="text-align: center">

          <asp:Button ID="Button1" runat="server" Height="26px" onclick="Button1_Click" 

            style="font-weight: 700" Text="Select" />

        </td>

      </tr>

      <tr>

        <td style="text-align: center">

          <asp:Label ID="Label1" runat="server"></asp:Label>

        </td>

      </tr>

      </table>

  

  </div>

  </form>

</body>{codeBox}


The code behind the C # code


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class Default8: System.Web. UI.Page

{

  protected void Page_Load(object sender, EventArgs e)

  {


  }

  protected void Button1_Click(object sender, EventArgs e)

  {

    if (radiored.Checked == true)

    {

      Label1.Text = "You Selected Red";

    }

    else if (radioblue.Checked == true)

    {

      Label1.Text = "You Selected Blue";

    }

    else

    {

      Label1.Text = "You Selected Green";

    }

  }

}{codeBox}

AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST