我爱Aspx >> Asp.Net >> RadioButton Web 控件RadioButton Web 控件的基本功能即是HTML 控件的<Input Type="Radio">。它的外观及功能我们已经在HTML 控件中展示过了,不过它比HTML 控件的功能更强,其使用语法如下:
<ASP:RadioButton
Id="被程序代码所控制的名称"
Runat="Server"
AutoPostBack="True | False"
Checked="True | False"
GroupName="群组名称"
Text="标示控件的文字"
TextAlign="设定文字在控件的左边或右边"
OnCheckedChanged="事件程序名称"
/>

下列范例码放置了两个RadioButton Web 控件,并在Page_Load 事件中设定控件的初始值。
<Html>
<Form Id="Form1" Runat="Server">
<ASP:RadioButton Id="Radio1" Text="第一个Radio" Runat="Server"/><br>
<ASP:RadioButton Id="Radio2" Text="第二个Radio" Runat="Server"/>
</Form>
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object,e As Eventargs)
Radio2.Checked="True" '让第二个Radio 变成选取
End Sub
</Script>
</Html>

这个范例中RadioButton 是两个独立的Web 控件,若我们希望在一群RadioButton Web 控制中只能选择一个时,只要将它们的GroupName 设为同一个即可。此时我们只能在这些RadioButtonWeb 控件中选择其中一个。下列程序代码范例中,我们限制了只能在三个RadioButton Web 控件中选择一个项目:
Ҷƪл˵?
RadioButtonList Web 控件[04-29]
ListItem Web 控件[04-29]
CheckBox Web 控件[04-29]
DropDownList Web 控件[04-29]
DropDownList Web 控件[04-29]
RequireFieldValidator Web 控件[04-29]
ListBox Web 控件[04-29]
进阶Web控件--数据验证Web控件[04-29]
CompareValidator Web 控件[04-29]
CustomValidator Web 控件[04-29]
RadioButtonList Web 控件[04-29]
ListItem Web 控件[04-29]
CheckBox Web 控件[04-29]
CheckBoxList 控件[04-29]
DropDownList Web 控件[04-29]
DropDownList Web 控件[04-29]
RequireFieldValidator Web 控件[04-29]
ListBox Web 控件[04-29]
进阶Web控件--数据验证Web控件[04-29]
CompareValidator Web 控件[04-29]