gpt4 book ai didi

c# - 将 Asp 单选按钮属性(值)设置为字符串

转载 作者:搜寻专家 更新时间:2023-10-31 22:46:38 25 4
gpt4 key购买 nike

在下面提到的代码中,我将属性“值”添加到单选按钮。我需要知道如何将单选按钮的“值”属性设置为字符串。

提前致谢。

protected void Page_Load(object sender, EventArgs e)
{
RadioButton rdoAuthModeSingleFactor = new RadioButton();
rdoAuthModeSingleFactor.Text = authModeObj["AuthenticationModes"].ToString();
string authModeIdVal = authModeObj["AuthenticationModeId"].ToString();
rdoAuthModeSingleFactor.GroupName = "AuthModes";
rdoAuthModeSingleFactor.ID = "AuthModeRdoID";
rdoAuthModeSingleFactor.Attributes.Add("Value", authModeIdVal);
plhldrAuthModes1.Controls.Add(rdoAuthModeSingleFactor);
}

protected void btnAuthModeSave_Click(object sender, EventArgs e)
{
//Here iam using placeholder functionalities
// radio button object name is rdo
string authenticationModeCheckedVal = rdo.Text; // how to get value of radio button instead of text
}

最佳答案

对于网络表单:

<asp:RadioButtonList ID="rdogender" runat="server" RepeatLayout="Flow">
<asp:ListItem Value="Male">Male</asp:ListItem>
<asp:ListItem Value="Female">Female</asp:ListItem>
</asp:RadioButtonList>

和CS-在一些按钮点击

string value=rdogender.SelectedItem.Value.ToString();

希望你理解并为你工作。

关于c# - 将 Asp 单选按钮属性(值)设置为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17035914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com