简体   繁体   English

mvc3 cshtml razor和if语句如何在视图中使用它

[英]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 @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? 有没有关于mvc3 razor这个例子的好网页?

做就是了:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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