Does anyone know how to configure visual studio to correctly format code segments within a View
This annoys the crap outta me!:
<select>
<%
foreach(Height height in ViewData.Model.Heights)
{%>
<option value="<%=height.ID %>"><%=height.Value%></option>
<%
}%>
</select>
It should be like this:
<% foreach(Height height in ViewData.Model.Heights) { %>
<option value="<%=height.ID %>"><%=height.Value%></option>
<% } %>
</select>
I can fix it manually but whenever I reformat, or change some of the code close to the braces it screws up again!
This operator is useful in conjunction with other Razor server side operators when you want to output something as a literal text. For example: @if (model. Foo) { @:Some text to be written directly. }
Using @: to explicitly indicate the start of content We are using the @: character sequence to explicitly indicate that this line within our code block should be treated as content.
Razor is a markup syntax that lets you embed server-based code into web pages using C# and VB.Net. It is not a programming language. It is a server side markup language. Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. You can use it anywhere to generate output like HTML.
Razor is one of the view engines supported in ASP.NET MVC. Razor allows you to write a mix of HTML and server-side code using C# or Visual Basic.
After the auto formatting takes place hit cntrl-z, it will undo the auto-formatting only and not rearrange your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With