Onlineatoz.net | ToolBox HTML Control HTMLRadio

ToolBox HTML Control HTMLRadio

HTML Radio Web Server Control

In ASP.NET environment,This article describes you how to work with HTML Radio Control.In HTML environment, Radio is an object that represents a Radio in an HTML form. The Radio control in a HTML form contains all instance of an <input type="radio"> tag.

The primary mechanism of the Radio control is to selecting the optional item. For instance, there are two items called male and female that any one can be choosen by radio button.

There are several functions available to access the HTML Radio.some of its funtions are as follows,

  • document.getElementById()
  • document.getElementByName()
Radio Objects Properties
  • id -Sets or returns the id of a Radio
  • form -Returns a reference to the form that contains the Radio
  • accessKey -Sets or returns the keyboard key to access a Radio
  • alt -Sets or returns an alternate text to display if a browser does not support Radio
  • disabled -Sets or returns whether or not a Radio should be disabled
  • tabIndex -Sets or returns the tab order for a Radio
  • name -Sets or returns the name of a Radio
  • type -Returns the type of form element a Radio is
  • checked -Sets or returns whether or not a Radio should be checked
  • defaultchecked - Returns the default value of the checked attribute
  • value -Sets or returns the text that is displayed on the Radio
  • title -Sets or returns an element's advisory title
  • lang -Sets or returns the language code for an element
  • dir -Sets or returns the direction of text
  • className -Sets or returns the class attribute of an element
Radio Objects Methods
  • blur() -Performs focus when leave from the control
  • click() -Simulates a mouse-click on a Radio
  • focus() -Performs focus when enter into the control

The following code snippets explains you the HTML Radio in the web form.

in .aspx.cs page,

void Button1_Click(object sender, EventArgs e) 
      {

         if (rb1.Checked == true)
            Span1.InnerHtml = "Option 1 is selected";
         else if (rb2.Checked == true)
            Span1.InnerHtml = "Option 2 is selected";
         else if (rb3.Checked == true)
            Span1.InnerHtml = "Option 3 is selected";
      }
        

in .aspx page,

<form id="Form2" runat=server>
      <h3>HtmlInputRadioButton Sample</h3>
      <input type="radio" 
             id="rb1" 
             name="Mode" 
            runat="server"/>
      Option 1<br>
      <input type="radio" 
             id="rb2" 
             name="Mode" 
            runat="server"/>
      Option 2<br>
      <input type="radio" 
             id="rb3" 
             name="Mode" 
             runat="server"/>
      Option 3
      <p>
      <span id="Span1" runat="server" />
      <p>
      <input type="button" 
             id="Button1" 
             value="Enter" 
             OnServerClick="Button1_Click" 
             runat="server">
   </form>
 
Related Links


Posted by: Admin
Posted on: 9/11/2011 at 8:34 PM
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed