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
Post a Comment