RadioButtonList
RadioButtonList Example
@inherits ControlComponent
<asp.RadioButtonList @ref="this.radioButtonList">
<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.ListItem>Item 5</asp.ListItem>
<asp.ListItem>Item 6</asp.ListItem>
</asp.RadioButtonList>
<br />
<asp.CheckBox @ref="this.chkLayout" Text="Display Table Layout" AutoPostBack="true" Checked="true"
OnCheckedChanged="this.ChkLayout_CheckedChanged" />
<br />
<asp.CheckBox @ref="this.chkDirection" Text="Display Horizontally" AutoPostBack="true"
OnCheckedChanged="this.ChkDirection_CheckedChanged" />
<br />
<asp.Button Text="Submit" OnClick="this.Button1_Click" />
<br />
<asp.Label @ref="this.label" FontNames="Verdana" FontSize="8pt" />
@code {
private RadioButtonList radioButtonList;
private CheckBox chkLayout;
private CheckBox chkDirection;
private Label label;
protected void Button1_Click(object sender, EventArgs e)
{
if (radioButtonList.SelectedIndex > -1)
{
label.Text = "You selected: " + radioButtonList.SelectedItem.Text;
}
}
protected void ChkLayout_CheckedChanged(object sender, EventArgs e)
{
if (chkLayout.Checked == true)
{
radioButtonList.RepeatLayout = RepeatLayout.Table;
}
else
{
radioButtonList.RepeatLayout = RepeatLayout.Flow;
}
}
protected void ChkDirection_CheckedChanged(object sender, EventArgs e)
{
if (chkDirection.Checked == true)
{
radioButtonList.RepeatDirection = RepeatDirection.Horizontal;
}
else
{
radioButtonList.RepeatDirection = RepeatDirection.Vertical;
}
}
}
RadioButtonList Data Binding Example
@inherits ControlComponent
@inject HttpClient Http
<asp.RadioButtonList @ref="this.radioButtonList"
DataSourceID="FreeDataSource1"
DataTextField="ColorTextField"
DataValueField="ColorValueField">
</asp.RadioButtonList>
<asp.FreeDataSource ID="FreeDataSource1" OnExecuteSelected="sender => this.colors" />
<br />
<asp.Button Text="Submit" OnClick="this.Button1_Click" />
<br />
<asp.Label @ref="this.label" FontNames="Verdana" FontSize="8pt" />
@code {
private Color[] colors;
private RadioButtonList radioButtonList;
private Label label;
protected override async Task OnInitializedAsync()
{
colors = await Http.GetFromJsonAsync<Color[]>("sample-data/colors.json");
}
protected void Button1_Click(object sender, EventArgs e)
{
if (radioButtonList.SelectedIndex > -1)
{
label.Text = "You selected: " + radioButtonList.SelectedItem.Text;
}
}
public class Color
{
public string ColorTextField { get; set; }
public string ColorValueField { get; set; }
}
}
RadioButtonList Metadata
| Name | Type | Kind | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AccessKey | String | Parameter | ||||||||||||||||||
| AppendDataBoundItems | Boolean | Parameter | ||||||||||||||||||
| Attributes | IReadOnlyDictionary | Parameter | ||||||||||||||||||
| AutoPostBack | Boolean | Parameter | ||||||||||||||||||
| BackColor | String | Parameter | ||||||||||||||||||
| BorderColor | String | Parameter | ||||||||||||||||||
| BorderStyle | BorderStyle | Parameter | ||||||||||||||||||
| BorderWidth | String | Parameter | ||||||||||||||||||
| CausesValidation | Boolean | Parameter | ||||||||||||||||||
| CellPadding | Int32 | Parameter | ||||||||||||||||||
| CellSpacing | Int32 | Parameter | ||||||||||||||||||
| ClientIDMode | ClientIDMode | Parameter | ||||||||||||||||||
| CssClass | String | Parameter | ||||||||||||||||||
| DataMember | String | Parameter | ||||||||||||||||||
| DataSourceID | String | Parameter | ||||||||||||||||||
| DataGroupField | String | Parameter | ||||||||||||||||||
| DataGroupFormatString | String | Parameter | ||||||||||||||||||
| DataTextField | String | Parameter | ||||||||||||||||||
| DataTextFormatString | String | Parameter | ||||||||||||||||||
| DataValueField | String | Parameter | ||||||||||||||||||
| Enabled | Boolean | Parameter | ||||||||||||||||||
| FontBold | Boolean | Parameter | ||||||||||||||||||
| FontItalic | Boolean | Parameter | ||||||||||||||||||
| FontNames | String | Parameter | ||||||||||||||||||
| FontOverline | Boolean | Parameter | ||||||||||||||||||
| FontSize | String | Parameter | ||||||||||||||||||
| FontStrikeout | Boolean | Parameter | ||||||||||||||||||
| FontUnderline | Boolean | Parameter | ||||||||||||||||||
| ForeColor | String | Parameter | ||||||||||||||||||
| Height | String | Parameter | ||||||||||||||||||
| ID | String | Parameter | ||||||||||||||||||
| LabelMode | LabelMode | Parameter | ||||||||||||||||||
| RenderWhenDataEmpty | Boolean | Parameter | ||||||||||||||||||
| RepeatColumns | Int32 | Parameter | ||||||||||||||||||
| RepeatDirection | RepeatDirection | Parameter | ||||||||||||||||||
| RepeatLayout | RepeatLayout | Parameter | ||||||||||||||||||
| SelectedValue | String | Parameter | ||||||||||||||||||
| Style | String | Parameter | ||||||||||||||||||
| TabIndex | Int16 | Parameter | ||||||||||||||||||
| TextAlign | TextAlign | Parameter | ||||||||||||||||||
| ToolTip | String | Parameter | ||||||||||||||||||
| ValidationGroup | String | Parameter | ||||||||||||||||||
| Visible | Boolean | Parameter | ||||||||||||||||||
| Width | String | Parameter | ||||||||||||||||||
| OnCallingDataMethods | CallingDataMethodsEventHandler | Event | ||||||||||||||||||
| OnCreatingModelDataSource | CreatingModelDataSourceEventHandler | Event | ||||||||||||||||||
| OnDataBinding | EventHandler | Event | ||||||||||||||||||
| OnDataBound | EventHandler | Event | ||||||||||||||||||
| OnDisposed | EventHandler | Event | ||||||||||||||||||
| OnInit | EventHandler | Event | ||||||||||||||||||
| OnLoad | EventHandler | Event | ||||||||||||||||||
| OnPreRender | EventHandler | Event | ||||||||||||||||||
| OnSelectedIndexChanged | EventHandler | Event | ||||||||||||||||||
| OnTextChanged | EventHandler | Event | ||||||||||||||||||
| OnUnload | EventHandler | Event | ||||||||||||||||||
| ListItem | asp.ListItem | InnerProperty | ||||||||||||||||||
|
||||||||||||||||||||