With the advent of Visual Studio.NET the landscape of developer tools has changed significantly. The bar for quality of these tools has been raised. Web developers have been empowered with a powerful addition to their toolset. I have yet to meet someone who misses the old Interdev with its clumsiness and many corks. Nevertheless, as any evolving product, VS.NET 2003 (the latest version as of the time of this writing) has several features that make no sense. They can truly give you a hair-pulling experience. Here they are...
Beware Of The CSS Source Editor
VS.NET provides what seems at first sight a helpful feature—CSS Source Editor. Simply add a CSS file to a web project and double click it. Unless you change the defaults the file will be displayed in the built-in CSS Source Editor. Compared to other professional tools out there, such as Dreamweaver, TopStyle and the like, it offers very little: a CSS outline panel with elements, classes, element IDs grouped for your convenience, and the ubiquitous IntelliSense (whose accuracy I question).
So what’s the problem? Let’s walk through an exercise. Add a bogus definition:
p {
border: 1px solid #000;
}
This declaration adds a 1px black border around every paragraph tag. Now right click on the border definition and select "Build Style...". Nice! A dialog box with a multitude of options to visually tweak the style declaration! With or without changing anything click Ok. Voilà! VS.NET gives you a hand by formatting the border declaration for you:
p
{
border-right: #000 1px solid;
border-top: #000 1px solid;
border-left: #000 1px solid;
border-bottom: #000 1px solid;
}
Now, this is where a nagging question comes to my mind: who in sane mind would want to expand a compact shortcut property into full property definitions? Unless you want to change the border color or width you wouldn’t do it.
The moral of this story is use the Property Builder at your own risk as it has the tendency to destroy your CSS. I’ve looked through all settings related to it and couldn’t find a way to stop the CSS Source Editor from messing up my stylesheet.
There’s a way out though. If you own a copy of Dreamweaver, TopStyle or any other CSS editor you may want to associate CSS files with it. Right click any CSS file, select "Open With...", click "Add...", locate an appropriate executable, and give the association a friendly name. Once you’re done select it in the "Select a program to open:" list and click "Set as Default". Now every time you open up a CSS file from within VS.NET your own CSS editor will pick it up.
Beware Of The HTML Designer View
This one is outrageous. If you use VS.NET much I’m sure you’ve run into it. Add a web form to a web project. Switch to the HTML view, add some controls by hand. Then switch into the Design mode. Aaaaaaah. You fell for it too! Now switch back to the HTML view and behold the crippled HTML. This is especially aggravating if you have a large page with a bunch of controls and you spent so much time carefully indenting them and making sure all tags were lower case. But instead you get "smart formatting" applied for you. This is twice is aggravating if you’re laying out XHTML because VS.NET capitalizes tags (WHY???) and replaces inline styles with element attributes:
<asp:Label id="lblTest" Runat="server" style="width:100px;" />
becomes
<asp:Label id="lblTest" Runat="server" Width="100"/>
This is a very simple example but you get the point.
I can’t even count how many times people in user groups would cry for help asking how to turn this feature off. You rush to Tools->Options->HTML/XTML and disable everything under "Apply Automatic Formatting". Still no dice. The bad news you can’t turn this feature off. It just doesn’t work. The only solution that I know of is to select Undo, or press CTRL-Z, right after you switch from the design view to the HTML view. It almost seem like VS.NET executes this extra step that messes up the markup. Better yet, if you were lucky enough to have the page in VSS, roll back the changes.
I don’t understand why there has never been a service pack for VS.NET to address this bug. It’s such an essential feature but you are forced to resort to copying your markup into Textpad and then back to preserve formatting if you need to switch to the designer for a second. Absurd.
The good news the upcoming reincarnation of VS.NET code-named "Whidbey" will be void of this bug. Both Scott Guthrie and Scott Louvau said so.
I remember hearing back in 2000, at the beginnig of days of ASP.NET, that VS.NET allowed to separate the jobs of developers and designers thanks to the code-behind feature. Code-behind is really great, but if you are a web designer and you do use VS.NET for layout in your line of work drop me a line, please.