<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" Runat="Server">
<table width="100%" cellpadding="2" cellspacing="0">
<tr valign="top" class="ArticleTitle">
<td style="padding-left:10px;" valign="middle">
asp:RadioButton control</td>
</tr>
<tr>
<td class="ArticleContents">
RadioButton control is used to give single select option to the user from multiple items.
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" Runat="Server">
<div class="ArticleContents">
RadioButton control is used to give single select option to the user from multiple items. When it is rendered on the page, it is implemented through <input type=radio></input> HTML tag.
Its properties like <span class="DemoCP">BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. </span> are implemented through style properites of <input>.
<p> </p>
Following are some important properties that are very useful.
<table width="100%" class="TutoPropPlaceHolder" border="1" cellpadding="2" cellspacing="1">
<tr>
<td class="DemoCP">AutoPostBack</td>
<td>
Form is automatically posted back when Radio button selection is changed.
</td>
</tr>
<tr>
<td class="DemoCP">CausesValidation</td>
<td>
true/false. If true, Form is validated if Validation control has been used in the form.
</td>
</tr>
<tr>
<td class="DemoCP">Checked</td>
<td>
true/false. If true, Radio button is selected by default.
</td>
</tr>
<tr>
<td class="DemoCP">OnCheckedChanged</td>
<td>
Fires when Radio button selection changes. This works only if <span class="DemoCP">AutoPostBack</span> property is set to true.
</td>
</tr>
<tr valign="Top">
<td class="DemoCP">ValidationGroup</td>
<td>
Used to put a radio button under a particular validation group. It is used when you have many set of form controls and by clicking a paricular button
you want to validate a particular set of controls only.
</td>
</tr>
<tr valign="Top">
<td class="DemoCP">GroupName</td>
<td>
It is used a group a set of radion buttons so only one of them can be selected at a time.
</td>
</tr>
</table>
<!-- START - Demo Section -->
<table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
<tr>
<td class="DemoTitle">
DEMO : RadioButton
</td>
<td align="right">
<a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/controls/radiobutton.aspx" target="_blank">Show Source Code</a>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td>
1st set of Radio buttons without AutoPostBack<br />
<asp:RadioButton ID="RadioButton1" runat="Server" GroupName="1stGroup" Text="Red" Checked="True" />
<asp:RadioButton ID="RadioButton2" runat="Server" GroupName="1stGroup" Text="Blue" />
<asp:RadioButton ID="RadioButton3" runat="Server" GroupName="1stGroup" Text="Green" />
</td>
<td>
2nd set of Radio buttons with AutoPostBack<br />
<asp:RadioButton ID="RadioButton4" runat="Server" GroupName="2ndtGroup" Text="Red" Checked="True" OnCheckedChanged="FireOnCheckedChanged" AutoPostBack="true" />
<asp:RadioButton ID="RadioButton5" runat="Server" GroupName="2ndtGroup" Text="Blue" OnCheckedChanged="FireOnCheckedChanged" AutoPostBack="true" />
<asp:RadioButton ID="RadioButton6" runat="Server" GroupName="2ndtGroup" Text="Green" OnCheckedChanged="FireOnCheckedChanged" AutoPostBack="true" />
</td>
</tr>
</table>
</td>
<td>
<asp:Label ID="lblLable" runat="server" EnableViewState="False"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<!-- START - Server Side Code -->
<pre>
// 1st set of Radio buttons without AutoPostBack
<asp:RadioButton ID="RadioButton7" runat="Server" GroupName="1stGroup" Text="Red" Checked="True" />
<asp:RadioButton ID="RadioButton8" runat="Server" GroupName="1stGroup" Text="Blue" />
<asp:RadioButton ID="RadioButton9" runat="Server" GroupName="1stGroup" Text="Green" />
// 2nd set of Radio buttons with AutoPostBack
<asp:RadioButton ID="RadioButton10" runat="Server" GroupName="2ndtGroup" Text="Red" Checked="True" OnCheckedChanged="FireOnCheckedChanged" AutoPostBack="true" />
<asp:RadioButton ID="RadioButton11" runat="Server" GroupName="2ndtGroup" Text="Blue" OnCheckedChanged="FireOnCheckedChanged" AutoPostBack="true" />
<asp:RadioButton ID="RadioButton12" runat="Server" GroupName="2ndtGroup" Text="Green" OnCheckedChanged="FireOnCheckedChanged" AutoPostBack="true" />
</pre>
<!-- END - Server Side Code -->
</td>
</tr>
</table>
<!-- END - Demo Section -->
</div>
<br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" Runat="Server">
</asp:Content>
Go Top