Auto-formatting embedded code in MVC

Is there a way to enable auto-formatting of C # code embedded inside HTML when creating an MVC application?

It seems to be using C # text editor settings for inline code, but I don't want to use the same formatting inside the HTML file as regular code files.

For example, if I write <% somecodehere { %> , then some HTML between them, and then I put <% } %> at the end, Visual Studio will automatically reformat the code:

 <% using (Html.BeginForm()) {%> ... <% }%> 

For MVC code, I think it looks as neat as this

 <% using (Html.BeginForm()){ %> ... <% } %> 

But I don’t see how to change this without messing up the formatting for regular code files.

+7
source share
2 answers

I myself tried to do this, but did not prevail. If you earn it so that it looks good in one place, it will look bad in another. My best recommendation is to switch to a razor, there are ways to use web form submissions and razor views in the same project to ensure smooth migration.

http://www.eworldui.net/blog/post/2011/01/07/Using-Razor-Pages-with-WebForms-Master-Pages.aspx

0
source

You can disable this by selecting: Tools | Options on the left (you may need to check "show all settings"). Expand Text Editor. In the language you need, perhaps in your case a bit of HTML, in formatting, you can uncheck the box "automatically format to ...", there are several options that should do this.

0
source

All Articles