RadioButton Server Control
The RadioButton Server Control functionality is similar to the CheckBox control. But the design goes differently. RadioButton symbol is a round button, where as CheckBox symbol is a square box.
RadioButton control on a page takes the following construction:
Figure goes here…..
.aspx
<asp:RadioButton ID="rdlMale" Text="Male" GroupName="Gender" runat="server" />
<asp:RadioButton ID="rdlFemale" Text="Female" GroupName="Gender" runat="server" />
The user can select Male or Female at once. He cant select both as CheckBox does that. I used GroupName property to do this way.
Coming to the Event handler.
Figure Goes Here……
.aspx
<asp:RadioButton ID="rdlMale" AutoPostBack="true" Text="Male" GroupName="Gender"
runat="server" OnCheckedChanged="rdlMale_CheckedChanged" />
<asp:RadioButton ID="rdlFemale" AutoPostBack="true" Text="Female" OnCheckedChanged="rdlMale_CheckedChanged"
GroupName="Gender" runat="server" />
<br />
<asp:Label ID="lblOutput" runat="server" ></asp:Label>
.cs
protected void rdlMale_CheckedChanged(object sender, EventArgs e)
{
if (rdlMale.Checked)
lblOutput.Text = "Welcome Mr.";
else
lblOutput.Text = "Welcome Mrs.";
}
ASP Standard Controls
- ASP Label Control
- ASP TextBox Control
- ASP Button Control
- ASP Link Button Control
- ASP ImageButton Control
- ASP HyperLink Control
- ASP DropDownList Control
- ASP ListBox Control
- ASP CheckBox Control
- ASP CheckBoxList Control
- ASP RadioButton Control
- ASP RadioButtonList Control
- ASP Image Control
- ASP ImageMap Control
- ASP Calendar Control
- ASP Table Control
- ASP BulletedList Control
- ASP Hidden Control
- ASP Literal Control
- ASP AdRotator Control
- ASP Panel Control
- ASP PlaceHolder Control
- ASP FileUpload Control
- ASP UserControl
- ASP Custom Control
Random Tips and Tricks
Tuesday, September 28, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment