简体   繁体   中英

mvc3 cshtml razor and if statement how to use it in view

@foreach (var articleOnFirstPage in Model.ArticlesOnFirstSite)
{
    <td> 
    if (@article.Deleted == true) 
    {   
        @:Yes
    }
    else
    {
        @:No
    }
    </td>
}

can i do this like @article.Deleted == true ? @:Yes : @:No @article.Deleted == true ? @:Yes : @:No ?

i try but i get error. Is there any good web page with this examples for mvc3 razor?

做就是了:

@(article.Deleted ? "Yes" : "No")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM