开发者

MVC Html Layout C# code formatting

开发者 https://www.devze.com 2022-12-31 23:00 出处:网络
I insert into asp.net mvc views C# logic that manages layout like the following: <% if (Model.People.Count > 0 ) { %>

I insert into asp.net mvc views C# logic that manages layout like the following:

<% if (Model.People.Count > 0 ) { %>
   <% foreach (var person in Model.People) { %>      
      ...
<% }} else { %>
   <span class="error">Sorry, no people</span>
<%} %>

I try to minimize <% %> code placing "{" symbol on the same line as it's condition (java-style). Html layout looks more clear to me after that.

Do you apply C# formatting rules to <% %> html injections "}" should be on a new line or manage layout in different way?

Thank you in adv开发者_StackOverflowance!


Its totally up to you, whatever you find is more readable and maintainable.

The less inline server blocks you have the better though (in terms of preventing run-time code compilation errors).

0

精彩评论

暂无评论...
验证码 换一张
取 消