When typing code in a .aspx file (an MVC view in this case), Visual Studio applies two types of formatting, one to the regular html tag structure (which can be controlled from Tools->Options->Text Editors->Html) and another to content inside the <% %> tags.
I've run into two annoyances with the second type of automatic formatting, the <% %> content formatting.
首先是如何将新行添加到语句块:
如果我打这个:
<% if(condition) { %>
...
<% } %>
它会自动更正为:
<% if(condition)
{ %>
...
<% } %>
如果这是一个错误,那么修正是正确的.cs文件,用于标记汤.我发现第一个aspx文件的可读性要高得多.有没有一种方法可以在不影响文件格式的情况下关闭此行为.cs文件?
第二,每当我写这样的东西:
<%=Html.ActionLink("Report","ListItems") %>
我找不到一种方法自动将其格式化为此格式(在适当的地方添加空格):
<%=Html.ActionLink("Report", "ListItems") %>
在代码中,你通常需要一个;或者}表示您已经完成了一行/一段代码,以便Visual Studio可以对其进行格式化.有没有办法给a<;%=表达方式?
CLARIFICATION
This question is about the formatting of code inside <% %> tags without affecting the formatting of regular C# source files. It says right in the first paragraph that I am completely aware of the Text Editors menu.