Is it possible to change the way Resharper 4.5 code is formatted in aspx / ascx files?

I keep hitting ctrl-z to undo the automatic formatting that is happening in templates. For example, Resharper would like to format the foreach loop like this:

<%
  foreach (var product in Model.Items)
  { %>
      <li><%= product.Name %></li>
<% } %>

      

It's fine in C # code files, but it's just not useful in templates. I would rather format it this way

<% foreach (var product in Model.Items) { %>
    <li><%= product.Name %></li>
<% } %>

      

+1


a source to share


3 answers


Open Visual Studio Go to Resharper> Options ...> Langauges> C #> Formatting Style> Bracket outline> Other

Change to "At the end of the line (no space)"



Note that this will affect your C # as well.

It is a little annoying that you cannot specify a different sytle code for your aspx pages, as often you need something different.

+4


a source


Resharper doesn't allow for custom formatting. You can only change the predefined formatting by parameters. I poked and didn't see the formatting options for <%%. Sorry: (



+1


a source


As of ReSharper 7.1 (currently in EAP), it is possible to use K&R style in ASP and Razor while continuing to use BSD for C #. ReSharper | Options → Code Editing | ASP.NET | Editor and Formatting -> Override anchor style for C # to always use "At the end of line (K & R style)"

0


a source







All Articles