I have a file in my project called StyleSheet.css.
Here, I have the classes for each element on my web form.
For example:
.selectEnvironment
{
background-color: #FF0000;
}
Then I go to my control on my web form (a drop down list) and I add the CSS class to it:
<div>
<asp:DropDownList ID="ddlEnvironment" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlEnvironment_SelectedIndexChanged" CssClass="selectEnvironment">
<asp:ListItem>Select Environment</asp:ListItem>
<asp:ListItem>Development</asp:ListItem>
<asp:ListItem>Staging</asp:ListItem>
<asp:ListItem>Production</asp:ListItem>
</asp:DropDownList>
</div>
This is not working. The background color of this is not changing to red.
What am I doing wrong? I’m completely new to front end web development.
Drag style sheet from Solution Explorer into your page, or master page header, in design view. This is the easiest way to make sure that the style sheet path is correct 😉