溫馨提示×

C# radiobutton 在Web應用中的實現

c#
小樊
89
2024-07-13 22:37:24
欄目: 編程語言

在ASP.NET Web應用中,可以使用ASP.NET的RadioButton控件來實現單選按鈕(RadioButton)。以下是一個簡單的示例:

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
    <asp:ListItem Text="Option 1" Value="1"></asp:ListItem>
    <asp:ListItem Text="Option 2" Value="2"></asp:ListItem>
    <asp:ListItem Text="Option 3" Value="3"></asp:ListItem>
</asp:RadioButtonList>

在代碼后端中,可以通過以下方式來獲取選中的單選按鈕的值:

string selectedValue = RadioButtonList1.SelectedValue;

也可以通過以下方式來檢查哪個單選按鈕被選中:

if (RadioButtonList1.SelectedItem != null)
{
    string selectedText = RadioButtonList1.SelectedItem.Text;
    string selectedValue = RadioButtonList1.SelectedItem.Value;
}

這樣就可以在ASP.NET Web應用中實現單選按鈕(RadioButton)的功能。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女