Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to prevent Visual Studio 2010 formatting C# code in ASP.NET MVC views?

I'd like Visual Studio to continue automatically formatting my .cs files, but is there a way to prevent it auto-formatting C# code in between the <% %> tags in ASP.NET MVC views because it really makes a mess of it?

like image 816
Kev Avatar asked Sep 30 '10 22:09

Kev


Video Answer


2 Answers

As far as I know there isn't a way to turn off the formatting just in ASP.NET files as it uses the rules for C# in Tools -> Options -> Text Editor -> C#.

like image 83
zainnab Avatar answered Oct 16 '22 00:10

zainnab


There is no way to do it and it is a huge time waster fixing up the formatting in .aspx pages over and over again. It drives me nuts.

There are two connect issues/bugs for this. One was marked as fixed for months but the latest response does not look like anything was even done.

https://connect.microsoft.com/VisualStudio/feedback/details/514691/add-aspx-or-inline-c-as-an-option-in-text-editor-formatting-options

https://connect.microsoft.com/VisualStudio/feedback/details/586729/support-c-formatting-options-for-aspx-pages

like image 42
Jon Kragh Avatar answered Oct 16 '22 00:10

Jon Kragh