Sunday, February 8, 2015

SOLVED: SharePoint Designer Inserting Blank Lines

Frustrated by Designer adding unwanted blank lines to your .aspx or .master pages?

Here's the problem:


The first time the file is saved in SharePoint Designer blank lines are inserted or added like this...




The second time the file is saved Designer doubles the number of blank lines, plus adds an extra line - a total of three blank lines...






The third time the file is saved it doubles again, adding one line for a total of seven blank lines...





The fourth time the file is saved a total of fifteen blank lines appear (double previous plus one)....

It's simple to see how after several iterations of changes hundreds or thousand of unwanted blank lines can be inserted.





Notice the culprit here - it occurs around lines of literal text within tag-blocks...

Where ever you encounter <SharePoint:ScriptBlock> and <SharePoint:StyleBlock> tags you will experience this problem:
   

Here's the fix (read all the way to the end):

Simply add an HTML/XML comment tag right after Script or Style Tags.  Like this...


...and that's it.  Fixed.  Save as many times as you want - no more blank lines inserted between these tags.

Crucial Tips!

  • Notice that the comment tag must be on the same line as the <SharePoint:...block> tag. Must!  If you put it on it's own line the problem will persist
  • Adding this text is necessary for every <SharePoint:...block> tag on the page.