in .net controls tend to be styled using in-line styling. You can set styling in the properties section of the Visual Studio IDE as opposed to adding a class id to it. But doesn't this go against best practice for CSS. CSS should normally all be in a separate stylesheet shouldn't it?
So what do the pros do about this? Or would it simply be too time consuming to create separate styling for the controls in a separate stylesheet?
Don't know where you got that VS likes in-lines, it gives you the option, but if you are doing more than one or two properties, or reusing them at any time, it always pays to put them in a css file and linking to the page. In-lines take up space, kill reuse, and makes it infinitely harder to maintain. Even when you create a new project, the template usually creates a styles folder, best practice is to use it.
I love how people get an attitude when THEY asked for help.
When I say VS styles it in-line. If you have a control and then change its style properties through the IDE it always add the styles in-line doesn't it? You cannot say make a label bold and tell it to add the style to an external style sheet.
No you should be adding that style to the css instead of using inline, you would tell it to use a the class="mystyle", that way you can reuse it without having to retype/copy it to the label, you never know how many labels you will have that need to look like that. You have to maintain the css, but all you have to do is put in there, and then indicate the class to use it, far easier then anything else.
I love how people get an attitude when THEY asked for help.
But doesn't this go against best practice for CSS.
Yes it is against it.
Originally Posted by burnme
Even when you create a new project, the template usually creates a styles folder, best practice is to use it.
Though best practice a distinct guideline, this is arguably one of the arbitrary ones. I don't use the styles folder as I'm sure with lot's .NET developers do ... I use App_Themes.
I assume you are doing programmatic changes to the control. Doing so either call a separate Skin or attach a different CssClass. I prefer Skins as the skin can have multiple classes already attached to it and other settable properties. As much as possible my DOM Elements only contains class attributes. I do this using App_Themes. As much as possible I don't use the toolbox in the IDE and if I do I try not to forget to change the attributes.
Bookmarks