VS2010 and CSS: What is the best strategy to individually position form controls

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-05-03T22:34:19Z Indexed on 2010/05/05 1:38 UTC
Read the original article Hit count: 340

Filed under:
|
|
|

OK, I have a ton of controls on my page that I need to individually place. I need to set a margin here, a padding there, etc. None of these particular styles that I want to apply will be applied to more than control. What is the bets practice for determining at which level the style is placed, etc?

OK, my choices are

1) External CSS file

1A) Using ClientIdMode = Auto (the default)

I could assign a unique CssClass value to the ASP.NET control and, in the external CSS file, create a class selector that would only be applied to that one control.

1B) User Client ID = Predicatable

In the external CSS file, I could determine what the ID will be for the controls of interest and create an ID selector (#ControlID{Style} ). However, I fear maintenance issues due to including/removing parent containers that would cause the ID to change.

1C) User Client ID = Static.

I could choose static IDs for the controls such that I minimize the likelihood of a clash with auto generated IDs (perhaps by prefixing the ID with "StaticID_" and use an external stylesheet with ID selectors.

2) I could place the style right on the control. The only disadvantage here, as I see it, is that style info is brought down each time instead of being cached , which is what I'd get using an external CSS. If a style isn't resused, I personally don't see much benefit to placing it in an external file, though please explain why if you disagree. Is there moire of a reason that "It's nice to have all the CSS in one place?"

© Stack Overflow or respective owner

Related posts about css

Related posts about VS2010