Styles - general question

J

JezB

What's the generally accepted approach for using Styles and Stylesheets in a
web application based on .aspx files, Web Controls, User Controls, and
code-behind modules (c# in my case)? Most style and stylesheet guides on the
internet seem to be based on web sites (rather than applications) based on
relatively static textual information.

I have read that external stylesheet files are the way to go, but it seems
to me that these only lend themselves to defining "generic" styles shared by
all your pages, whereas page-specific settings (such as the position of each
item on the page) are most easily embedded directly into your .aspx pages as
in-line styles - but then you lose all the benefits of true separation
right? (maintainability, scalability, accessibility, etc).

It seems to me too cumbersome to separate such positioning of individual
items into page-specific stylesheet files - I'd have to define one class per
page control and then link the control to the class, correct?

Are there any guidelines available on this ? Could anyone point me in the
right direction ?
 
P

Patrice

This is just a general guideline (style separation) but in this particular
case, you won't loose that much IMO as changing the position of a control
would be anyway a change for just a single control (even if the style is an
external style sheet) opposed to a change of style that could apply to most
of the pages. AFAIK ASP.NET stores the position at the control level in
gridlayout mode.

What count IMO is the *usage* you'll have for the style. For example if a
position is used in a single page for a single control, its likely best tied
to this control. If a position is shared by multiple controls on various
pages, it could go into an external style sheet.

As a side note my personal preference is not to use absolute positionning
unless stricly needed...

Patrice
 
R

Robert Koritnik

I can only tell what approach do I use.

I have a general default.css on my app root. This file defines:
- general styles for HTML elements (like BODY, TD, A, etc. tags)
- style classes for controls that use the same layout (like .generalForm,
..textTitle, .subTitle etc.) with child tag/class definitions for automatic
style formatting within those controls

all styles that are like Web User Control specific are written within
controls ascx file. Maintainability in this case is not a problem, while
only that control uses some special style.

But if you really make a very well defined UI design layout you will
probably rarely find a usercontrol that should use specific styles.

On general html tag classes define just the general things like font, color,
etc. and then override or "add" other styles with style classes with child
dependence... So far I've never heard about any complaint regarding
maintainability of any of my colleges in development department.
 
J

JezB

Thanks group, this was what I was after. Although I understood the
possibilities it was difficult for me to see what would work best in
practice, not having ever built a real-world ASP.NET application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top