Are there any way to turn of the autoformatting of C# code that is inlined inside HTML when making a MVC application?
It seems that it use the C# Text Editor settings for the inline code as well, but I don't want to use the same formatting inside the HTML file as the normal code files.
For example, if I write <% somecodehere { %>
, then some HTML in between, and then I put the <% } %>
at the end, Visual Studio automatically reformats the code to this:
<% using (Html.BeginForm())
{%>
...
<%
}%>
For the MVC code, I think it looks much tidyer like this
<% using (Html.BeginForm()){ %>
...
<% } %>
But I don't see ho开发者_开发知识库w to change this without messing up the formatting for my normal code files.
I've myself tried to do this but to no prevail. If you get it to work so that it looks good in one place, it will look bad in another. My best recommendation is to switch to razor, there are ways to use webform views and razor views in the same project to provide seamless migration.
http://www.eworldui.net/blog/post/2011/01/07/Using-Razor-Pages-with-WebForms-Master-Pages.aspx
You can turn this off by going to: Tools|Options on the left (you may need to check "show all settings") expand Text Editor. In the language you need, probably in your case the HTML bit, in formatting, you can uncheck "automatically format on..." there are a few options, that should do it.
精彩评论