This is actually a pretty good question. I am asked this a lot by other colleagues and such.
First of all, let me say that I congratulate you for favoring ID selectors over classes where you can. That is the way CS is
supposed to work, yet many developers (especially ASP.NET guys it seems) never seem to grasp this, or understand why they should even care. So you are on the right track there.
Quote:
|
Override the UniqueID and ClientID properties
|
Really bad idea. You already know why.
Quote:
|
Create classes in my CSS and use the .NET CssClass attribute
|
Valid, yet far less than ideal. This is what I call the "Class-itis Approach", and unfortunately it is the one far too many ASP.NET devs seem to opt for. Seriously, if you're just going to stick class attributes on every tag, why not just use inline styles and forget the stylesheets altogether, right?
Quote:
|
Name my ID's within my CSS ctl00_ElementName
|
While not totally ideal either, this is by far the best approach of the three, as it comes the closest to the spirit of true CSS design principles. I've done it this way many
many times, and I can tell you that in actual practice it is far less problematic than you might otherwise think.
The key is to try to get as much of the UI in place as you can up front. Then, during the development phase, as long as the UI remains relatively stable, the chances that you will introduce a "breaking" change that messes up an ID is relatively low. If you happen to do that, just change the stylesheet to target the correct ID -- no big deal.
Once the UI is set, there is no chance at all that the IDs will just "spontaneously" change without intervention from you. In other words, if you don't mess with it, it won't mess with you.
Hope this helps.