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

Asked

Viewed 260 times

5

I came across the following piece of code:

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

Until then I didn’t know CssClass, would like to know what is the difference of it to only class and if the way we define the style is different, example:

/* O exemplo abaixo funcionaria para ambos? */
.labelFiltro {
  color: blue;
}
  • 1

    I think it’s . Net parameter for him to identify as a css class at parse time.

2 answers

6


In practice there is no difference.

CssClass is a property of controls web of ASP.NET - widely used in projects Webforms, I’m not sure there’s another case where they’re used.

He’s just a wrapper abstract for the attribute class HTML which aims to render to the attribute class.

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

Maybe you didn’t understand her purpose by writing the code directly into the design, but understand that because it is a property of the control, it can be manipulated through any place of your code, that is, it is possible to change the CSS class even being in the code-Behind.

3

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

CssClass is a style control property rotated on the server with framework . NET and rendered in the client as attribute class. The result is an HTML element with a 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 class styles labelFiltro to the HTML element:

.labelFiltro {
  color: blue;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.