Recent projects have moved me deep into the land of .NET. While .NET can be an extremely powerful framework for development that allows for ultra rapid development, sometimes it comes with a host of bang-your-head-through-your-monitor frustrations. Because I have such a deep flowing sense of compassion for monitors, I’m going to go over some tricks I’ve learned to tame the .NET beast.

On the plate for today: Why does Visual Studio mess up my code? For example, on the first day of development you typed in ”. On the next day, you open up your project and find ”. WTF. It gets even worse when Visual Studio decides to insert tables into your code.

Basically, Visual Studio is rewriting the entire page rather than maintaining the source as you typed it in. Apparently, this is a side effect of switching between design view and code view. Mikhail Arkhipov provides an in depth explanation on his developer site.

DON’T DO IT.

Because Microsoft is so insistent on “helping” programmers with their software, the number one fix for this problem is to simply stop using design view. You should be previewing your work on browsers anyway and so learning to code HTML by hand isn’t going to be the end of the world (it’ll actually be good for you). Until Microsoft gets it right, you can also use the following steps to keep your markup syntax safe.

TURN OFF AUTO FORMATTING.

Tools -> Options -> Text Editor -> HTML/XML -> Format Uncheck both Apply automatic formatting options. These checkboxes don’t always do the trick (go figure), but it’s a start.

MAKE CODE VIEW THE DEFAULT VIEW.

Tools -> Options -> HTML Designer -> General Make sure everything is checked to start in HTML view.

I also recommend you read Getting the most out of Visual Studio by Scott Mitchell, to learn how to take some additional precautions to making sure your syntax is safe with Visual Studio.

HTML Form Builder
Ryan Campbell

Dealing With .NET - Part I by Ryan Campbell

This entry was posted 5 years ago and was filed under Notebooks.
Comments are currently closed.

· 3 Comments! ·

  1. Shane Shepherd · 5 years ago

    Great Article! Thanks! Will we be seeing a Part II on this topic?

  2. Ryan Campbell · 5 years ago

    Wow! A .NET reader – nice to know they exist. Yeah there will be plenty of parts to this series. Most of them will be about te language rather than the IDE.

  3. Henrik · 5 years ago

    Hi there.

    Tools -> Options -> Text Editor -> HTML/XML -> Format -> Capitalization, then select “As Entered” on both drop down menues. Works for me. Still annoyed with the custom attribute on the body element and the custom meta tags VS adds tough..

    //Henke