Please visit our sponsors !
RadioButtonList Control
Definition and Usage
The RadioButton control is used to create a group of radio buttons.
Each selectable item in a RadioButtonList control is defined by a ListItem element!
Tip: This control supports data binding!
Properties
Property |
Description |
AutoPostBack |
A Boolean value that specifies whether the form should be
posted immediately after the index of the selected
item has changed or not. Default is false |
CellPadding |
The space, in pixels, between the cell walls and the radio
button group |
DataSource |
The data source to use |
DataTextField |
A field in the data source to be displayed in the radio
button group |
DataValueField |
A field in the data source that specifies the value of each
selectable item in the radio button group |
id |
A unique id for the control |
OnSelectedIndexChanged |
The name of the function to be executed when the index of
the selected
item has changed |
RepeatColumns |
The number of columns to use when displaying the radio
button
group. Default is "1" |
RepeatDirection |
Specifies whether the radio button group should be repeated
horizontally or vertically. Legal values are "Horizontal" and "Vertical".
Default is Vertical |
RepeatLayout |
The layout of the radio button group. Can be "Table" or
"Flow". Default is Table |
runat |
Specifies that the control is a server control. Must
be set to "server" |
TextAlign |
On which side of the radio button the text should appear
(right or left) |
Example 1
In the following example we declare one RadioButtonList
control and two CheckBox controls in an .aspx file. When the
status of the check box with id="chkLayout" is changed, the chk_Layout sub
routine is executed. This subroutine sets the RepeatLayout property of the
RadioButtonList control to Table if the chkLayout check box is checked, and to
Flow if the chkLayout check box is not checked. When the status of the check box
with id="chkDirection" is changed, the chk_Direction sub routine is executed. This subroutine
sets the RepeatDirection property of the RadioButtonList control to Vertical if
the chkDirection check box is checked, and to Horizontal if the chkDirection
check box is not checked:
<script runat="server">
Sub chk_Layout(sender As Object,e As EventArgs)
if chkLayout.Checked=True then
radiolist.RepeatLayout=RepeatLayout.Table
else
radiolist.RepeatLayout=RepeatLayout.Flow
end if
End Sub
Sub chk_Direction(sender As Object,e As EventArgs)
if chkDirection.Checked=True then
radiolist.RepeatDirection=RepeatDirection.Vertical
else
radiolist.RepeatDirection=RepeatDirection.Horizontal
end if
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:RadioButtonList id="radiolist" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
</asp:RadioButtonList>
<p>
<asp:CheckBox id="chkLayout" OnCheckedChanged="chk_Layout"
Text="Display Table Layout" Checked="true"
AutoPostBack="true" runat="server"/>
<br />
<asp:CheckBox id="chkDirection" OnCheckedChanged="chk_Direction"
Text="Display the RadioButtonList Vertically" Checked="true"
AutoPostBack="true" runat="server"/>
</p>
</form>
</body>
</html>
|
Jump to: Top of Page
or HOME or
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
|