Why can’t I collapse HTML in a master page? Oh, wait, I can! (Sort of.)

I’m going to file this one under Stupid Visual Studio tricks.

When editing a master page file in an ASP.NET project (or in my particular case, a SharePoint solution), it came clear that the normal display of the HTML source was missing the very useful expand/collapse option.

Exhibit 1.  Master page with no collapse

no collapse when viewing Master Page

With a hat tip to this Stackoverflow post, it appears re-opening the file and explicitly selecting the editor to use fixes this behavior, as shown below. (Note, I’m basing this on VS2010 SP1.  YMMV.)

First, right-click on the File, and select Open With…

Then select Master Page Editor (which is probably already marked as default) and click OK.

select editor

Then watch your cursor spin while some Visual Studio voodoo magic happens. When the file opens, you should see the expand/collapse boxes and lines.

master with collapse


The epic fail part comes when Visual Studio makes you do this every time you open the file.  

It is worth noting, however, that .aspx and .ascx pages are exempted from this bug feature.






Leave a Reply