2 回答
TA贡献1848条经验 获得超6个赞
我前面没有IDE,但是如果您希望它们切换为红色为红色而另一个为绿色,请尝试以下操作:
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.Items[0].Selected)
{
RadioButtonList1.Items[0].Attributes.Add("style", "background-color: green;");
RadioButtonList1.Items[1].Attributes.Add("style", "background-color: red;");
}
if (RadioButtonList1.Items[1].Selected)
{
RadioButtonList1.Items[1].Attributes.Add("style", "background-color: green;");
RadioButtonList1.Items[0].Attributes.Add("style", "background-color: red;");
}
}
TA贡献1775条经验 获得超8个赞
将autopostback属性设置为true
<asp:RadioButtonList CssClass="listitemcss" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" ID="RadioButtonList1" RepeatDirection="Horizontal" runat="server">
<asp:ListItem >
- 2 回答
- 0 关注
- 306 浏览
添加回答
举报