HOME

ASP.NET Tutorial
ASP.NET HOME
ASP.NET Intro
ASP.NET vs ASP
ASP.NET Install
ASP.NET Pages
ASP.NET Controls
ASP.NET Events

References
HTML Controls
Web Controls
Validation Controls

Please visit our sponsors !

HtmlInputRadioButton Control

Back

Definition and Usage

The HtmlInputRadioButton control is used to control an <input type="radio"> element. In HTML, this element is used to create a radiobutton.


Properties

Property Description
Checked Whether the control is selected
id A unique id for the control
Name The name of the radio button group
runat Specifies that the control is a server control.  Must be set to "server"

Example 1

In the following example we declare three HtmlInputRadioButton controls, one HtmlInputButton control, and one HtmlGeneric control  in an .aspx file (remember to embed the controls inside an HtmlForm control). When the submit button is triggered, the submit subroutine is executed. The submit subroutine may respond in three ways: if the radiobutton with id="r1" is selected, the server sends the message "Your favorite color is: Red" to the span control. If the radiobutton with id="r2" is selected, the server sends the message "Your favorite color is: Green" to the span control. If the radiobutton with id="r3" is selected, the server sends the message "Your favorite color is: Blue" to the span control:

<script runat="server">
Sub submit(Source As Object, e As EventArgs)
if r1.Checked=True then
  s1.InnerHtml="Your favorite color is: Red"
else
  if r2.Checked=True then
    s1.InnerHtml="Your favorite color is: Green"
  else
    if r3.Checked=True then
      s1.InnerHtml="Your favorite color is: Blue"
    end if
  end if
end if
End Sub
</script>
<html>
<body>
<form runat="server">
<p>Select your favorite color:</p>
<input id="r1" name="col" type="radio" runat="server">Red</input>
<input id="r2" name="col" type="radio" runat="server">Green</input>
<input id="r3" name="col" type="radio" runat="server">Blue</input>
<br /><br />
<input type="button" id="b1" value="Enter" OnServerClick="submit"
runat="server"/>
<br /><br />
<h3><span id="s1" runat="server" /></h3>
</form>
</span>
</body>
</html>


Back

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISCart
ASP Ecommerce & Shopping Cart


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search