ASP.NET MVC View Code Formatting - braces <% } %>
Asked Answered
M

1

7

Does anyone know how to configure visual studio to correctly format code segments within a View

This annoys the crap outta me!:

<select>
<%
foreach(Height height in ViewData.Model.Heights)
{%>
<option value="<%=height.ID %>"><%=height.Value%></option>
<%
}%>
</select>

It should be like this:

<% foreach(Height height in ViewData.Model.Heights) { %>
    <option value="<%=height.ID %>"><%=height.Value%></option>
<% } %>
</select>

I can fix it manually but whenever I reformat, or change some of the code close to the braces it screws up again!

Moschatel answered 25/11, 2009 at 13:46 Comment(3)
duplicate: #720542Kestrel
Bugs me too... looking forward to an answer.Muire
Removed MVC tag, this happens using webforms as well.Stipulate
S
1

After the auto formatting takes place hit cntrl-z, it will undo the auto-formatting only and not rearrange your code.

Stipulate answered 25/11, 2009 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.