views:

39

answers:

1

In Visual Studio while designing MVC views (in .aspx or .ascx files) I often use if statements. When I auto-format (Ctrl-K,D), VS wraps the braces in this really ugly and hard to read way:

<% if (Model.UserIsAuthenticated)
    {%>
(some HTML goes here...)
<%
    }%>

Is there any way to make Visual Studio auto-format like this instead:

<% if (Model.UserIsAuthenticated) { %>
(some HTML goes here...)
<% } %>

Or is there a better way to do this? I don't want to use Razor quite yet, but it looks like it would solve my problem. I'm using VS2010 with Resharper 5, if that helps.

+1  A: 

Under "Tools->Options->Text Editor->C#->Formatting->New Lines" are the rules for the open brace on each case (new methods, control blocks, etc), maybe you can find the one you want there.

FelixMM
That works for .cs files, but I'd like to only have this type of formatting for C# *within* a view page.
Mike Comstock
It worked for me on a View Page. I unchecked "Place open brace on new line for control blocks", try that one.
FelixMM
Right, it works on a view file, but then it also applies to all of the cs files. I'm trying to get it to only apply to the view files.
Mike Comstock