c# - How to disply a combination of text and looped vars in a foreach statement -


the following statement erring in mvc razor view.

 @foreach (var user in model.users)                 {                     <li><a href="#">add user</a></li>                     <li><a href="#">@user.firstname @user.lastname                          if(user.firstname != "")                         {                          @(@user.username)                         }else{                          @user.username                         }                         </a></li>                 } 

i cannot seem figure out razor handle properly.

most looking @if instead of if because starting html tag switches context "code" html , need switch "code".

@foreach(... { <span>...   @if(...)    {      <text>@user.username</text>   } </span> } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -