What is the difference between CssClass="example" and class="example"

5

I came across the following code snippet:

<asp:Label ID="lblStatus" CssClass="labelFiltro" runat="server" Text="Status:"></asp:Label>

Until then I did not know CssClass , I would like to know what is the difference of it to only class and if the way we define the style is different, eg:

/* O exemplo abaixo funcionaria para ambos? */
.labelFiltro {
  color: blue;
}
    
asked by anonymous 01.11.2017 / 15:24

2 answers

6

In practice there is no difference.

CssClass is a property of #

.

It is just an abstract for the class attribute of HTML that aims to render to the class attribute.

That is, if you use the property as CssClass="exemplo" , the generated HTML will be class="exemplo" .

You may not have understood the purpose of it by writing the code directly in the design file, but understand that because it is a control property, it can be manipulated anywhere in your code, that is, it is possible to change the CSS class even though it is in code-behind .

    
01.11.2017 / 16:03
3

The difference is that the former is handled on the server, while the latter is the result attribute of the first and handled on the client.

CssClass is a style control property run on the .NET framework server and rendered on the client as class attribute. The result is an HTML element with class specified in CssClass .

The result of <asp:Label ID="lblStatus" CssClass="labelFiltro" runat="server" Text="Status:"></asp:Label> would be:

<label id="lblStatus" class="labelFiltro">Status</label>

The code below will normally apply the styles of class labelFiltro to the HTML element:

.labelFiltro {
  color: blue;
}
    
01.11.2017 / 16:08