<asp:DropDownList AutoPostBack="true" ID="rating1" runat="server" Width="60px" onselectedindexchanged="rating1_SelectedIndexChanged"> <asp:ListItem>NA</asp:ListItem> <asp:ListItem>1</asp:ListItem> <asp:ListItem>1.5</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>2.5</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>3.5</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>4.5</asp:ListItem> <asp:ListItem>5</asp:ListItem> </asp:DropDownList>
protected void rating1_SelectedIndexChanged(object sender, EventArgs e) { float value = float.Parse(rating1.Text); if (value <= 3) { rating1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFF66"); } else { rating1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FF3300"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)