vex
07-10-2009, 03:13 PM
I am working on an application using CSS and Asp.net themes to skin the controls in my application (this is the first time I have used themes in asp.net).
The first thing I wanted to do was set a default skin to all my labels in the application which I accomplished by doing the following:
[CODE]
default.css
.LabelDefault {
font-family:tahoma,verdana,arial;
font-size:9pt;
color: #13446e;
margin-top: 5px;
}
[CODE]
default.skin
[CODE]
<asp:Label CssClass="LabelDefault" runat="server"></asp:Label>
[CODE]
aspx page
[CODE]
<asp:Label ID="lblLastNameLabel" runat="server" Text=""></asp:Label>
[CODE]
This works beautifully because once I referenced the default theme all the labels took on the skin.
The issue I’m having is what is the best practice and best way to go from here.
My application has hundreds of label controls and every label will have additional styles associated to them for example the WIDTH property. I know that adding [ICODE]width=”50px”[ICODE] to the control on the aspx page works but I want to keep it out of the code and in the skin/css files. So I added a new css style called [ICODE].Width85px{display:inline-block; Width: 85px;}[ICODE] and added a new label control to the skin file and gave it a Skin Id like [ICODE]SkinId=”skms_lblLastName”[ICODE] and added the Width85px CSS class to the CssClass property so it looks like this [ICODE]CssClass=” LabelDefault Width85px”[ICODE] then added the Skin Id to the control on the aspx page.
This seems like a lot of additional work considering that I have hundreds of controls in my app so I am now thinking that using the themes was not the right option since I could just create a single CSS class for each of the controls and apply only the CssClass to the control on the aspx page:
[CODE]
.ms_lblLastName {
font-family:tahoma,verdana,arial;
font-size:9pt;
color: #13446e;
margin-top: 5px;
display:inline-block;
Width: 85px;
}
[CODE]
Does anyone know what the benefits would be for continuing on the path of using the Skin and Css or the benefit of just using the Css?
The first thing I wanted to do was set a default skin to all my labels in the application which I accomplished by doing the following:
[CODE]
default.css
.LabelDefault {
font-family:tahoma,verdana,arial;
font-size:9pt;
color: #13446e;
margin-top: 5px;
}
[CODE]
default.skin
[CODE]
<asp:Label CssClass="LabelDefault" runat="server"></asp:Label>
[CODE]
aspx page
[CODE]
<asp:Label ID="lblLastNameLabel" runat="server" Text=""></asp:Label>
[CODE]
This works beautifully because once I referenced the default theme all the labels took on the skin.
The issue I’m having is what is the best practice and best way to go from here.
My application has hundreds of label controls and every label will have additional styles associated to them for example the WIDTH property. I know that adding [ICODE]width=”50px”[ICODE] to the control on the aspx page works but I want to keep it out of the code and in the skin/css files. So I added a new css style called [ICODE].Width85px{display:inline-block; Width: 85px;}[ICODE] and added a new label control to the skin file and gave it a Skin Id like [ICODE]SkinId=”skms_lblLastName”[ICODE] and added the Width85px CSS class to the CssClass property so it looks like this [ICODE]CssClass=” LabelDefault Width85px”[ICODE] then added the Skin Id to the control on the aspx page.
This seems like a lot of additional work considering that I have hundreds of controls in my app so I am now thinking that using the themes was not the right option since I could just create a single CSS class for each of the controls and apply only the CssClass to the control on the aspx page:
[CODE]
.ms_lblLastName {
font-family:tahoma,verdana,arial;
font-size:9pt;
color: #13446e;
margin-top: 5px;
display:inline-block;
Width: 85px;
}
[CODE]
Does anyone know what the benefits would be for continuing on the path of using the Skin and Css or the benefit of just using the Css?