开发者

MVC Html Layout C# code formatting

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜