<p>I'm in an <strong>ASP.NET UserControl</strong>.  When I type Control-K, Control-D to reformat all the markup, I get a series of messages from VS 2008:</p>

<p>"Could not reformat the document.  The original format was restored."</p>

<p>"Could not complete the action."</p>

<p>"The operation could not be completed.  The parameter is incorrect."</p>

<p>Anybody know what causes this?</p>

<p><strong>Edit</strong>: OK, that is just...weird.</p>

<p>The problem is here:</p>

<pre><code>&lt;asp:TableCell&gt;
  &lt;asp:Button Text="Cancel" runat="server" ID="lnkCancel" CssClass="CellSingleItem" /&gt;
&lt;/asp:TableCell&gt;
</code></pre>

<p>Somehow that asp:Button line is causing the problem.  But if I delete any individual attribute, the formatting works.  Or if I add a new attribute, the formatting works.  Or if I change the tag to be non-self-closing, it works.  But if I undo and leave it as-is, it doesn't work.</p>

<p>All I can figure is that this is some sort of really obscure, bizarre bug.</p>

[{'answer_id': 75283, 'author': 'John Sheehan', 'author_id': 1786, 'author_profile': 'https://Stackoverflow.com/users/1786', 'pm_score': 4, 'selected': True, 'text': "<p>There's probably some malformed markup somewhere in your document. Have you tried it on a fresh document?</p>\n"}, {'answer_id': 75305, 'author': 'Steve Morgan', 'author_id': 5806, 'author_profile': 'https://Stackoverflow.com/users/5806', 'pm_score': 1, 'selected': False, 'text': '<p>I encountered this for the first time a few weeks ago. I found it was down to invalid HTML. I had to cut out sections of content and paste it back in a little at a time to track down the problem.</p>\n'}, {'answer_id': 75308, 'author': 'palehorse', 'author_id': 312, 'author_profile': 'https://Stackoverflow.com/users/312', 'pm_score': 2, 'selected': False, 'text': '<p>Usually this sort of behavior is caused by invalid code.  It may only be invalid HTML causing it which would still allow the program to be compiled.</p>\n\n<p>For example, if tags are mismatched like this the IDE cannot reformat it.</p>\n\n<pre><code>&lt;div&gt;&lt;h1&gt;My Title&lt;/div&gt;&lt;/h1\n</code></pre>\n\n<p>Check your warnings to see if there are any entries pointing towards mismatched or unclosed tags.</p>\n'}, {'answer_id': 1849607, 'author': 'Calvin', 'author_id': 225079, 'author_profile': 'https://Stackoverflow.com/users/225079', 'pm_score': 1, 'selected': False, 'text': '<p>For me, I had some bogus characters in my markup code.  I only found this out by copy and pasting all my text into Notepad.  After that, I saw the bogus characters (showed up as little squares).  I just deleted those lines and retyped them and now everything is ok.</p>\n'}, {'answer_id': 2026362, 'author': 'Iman', 'author_id': 184572, 'author_profile': 'https://Stackoverflow.com/users/184572', 'pm_score': 2, 'selected': False, 'text': '<p>select the entire suspicious codes segments and use Ctrl+k,Ctrl+F to format only the selected segments instead of whole document .</p>\n\n<p>this way you can find the exact place of problems specially not closed or inappropriate closed tags and fix them .</p>\n\n<p>after all scanning segment by segment is done you can format the whole document for sure</p>\n'}, {'answer_id': 3549709, 'author': 'jordanbtucker', 'author_id': 164430, 'author_profile': 'https://Stackoverflow.com/users/164430', 'pm_score': 2, 'selected': False, 'text': '<p>For me, it\'s usually as issue with whitespace. To fix it, I open Find and Replace (CTRL+H), set <strong>Look in</strong> to "Current Document", check <strong>Use</strong> and select "Regular expressions". For <strong>Find what</strong> I enter ":b|\\n" (minus quotes), and for <strong>Replace with</strong> I enter a single space. Then I click <strong>Replace All</strong>.</p>\n\n<p>The steps above will replace all whitespace—including line breaks—with a single space, and the next time you format the document, you shouldn\'t get any errors. That is assuming you don\'t have malformed HTML.</p>\n'}, {'answer_id': 7331909, 'author': 'Olle89', 'author_id': 596847, 'author_profile': 'https://Stackoverflow.com/users/596847', 'pm_score': 3, 'selected': False, 'text': '<p>Did get the problem today.</p>\n\n<p>My solution: Restart Visual Studio</p>\n'}, {'answer_id': 41345298, 'author': 'ViVi', 'author_id': 5621607, 'author_profile': 'https://Stackoverflow.com/users/5621607', 'pm_score': 0, 'selected': False, 'text': '<p>Just to add some more information. This issue is caused due to some invalid markup in <code>html</code>. \nIt won\'t cause any blocking while running the application. </p>\n\n<p>Unfortunately the solutions mentioned here did not work for me.\n1. Restarting visual studio\n2. Replacing spaces using regex etc</p>\n\n<p>The best solution to fix the issue is to go to the specific line where the issue is caused and check that line for any invalid symbols like <code>,</code> or <code>"</code>. Just remove it and it will work fine.</p>\n'}, {'answer_id': 48592288, 'author': 'Sterling Diaz', 'author_id': 1228807, 'author_profile': 'https://Stackoverflow.com/users/1228807', 'pm_score': 2, 'selected': False, 'text': '<p>My problem was an extra <code>"</code>. Look carefully the html.</p>\n'}, {'answer_id': 58850704, 'author': 'ydinesh', 'author_id': 5891802, 'author_profile': 'https://Stackoverflow.com/users/5891802', 'pm_score': 0, 'selected': False, 'text': '<p>My issue is extra " in the value of html attribute, After removing this it is working fine for me.</p>\n'}, {'answer_id': 66116857, 'author': 'Prince Tyagi', 'author_id': 14886434, 'author_profile': 'https://Stackoverflow.com/users/14886434', 'pm_score': 1, 'selected': False, 'text': '<p>I had an unwanted semi-colon. But you may have quote (\'), double quote (&quot;), semi-colon (;) or any special character.</p>\n<p>So, editing my answer with more details and a screenshot because it still very active.</p>\n<p><a href="https://i.stack.imgur.com/7jn4Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7jn4Z.png" alt="enter image description here" /></a></p>\n<p>Go to that line by double clicking the error and search for the extra (unwanted) quote (\'), double quote (&quot;), semi-colon (;) or any special character. Remove it because it is causing the error.</p>\n'}]
['https://Stackoverflow.com/questions/75273', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5486/']