62,272
社区成员
发帖
与我相关
我的任务
分享<body>
<form runat="server">
<asp:DropDownList ID="DropDownList1" BackColor="Yellow" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="1" Text="1"></asp:ListItem>
<asp:ListItem Value="2" Text="2"></asp:ListItem>
</asp:DropDownList>
</form>
</body>
后台:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "1")
{
DropDownList1.Attributes["style"] = "background-color:Tan";
}
else
{
DropDownList1.Attributes["style"] = "background-color:SlateBlue";
}
}