我需要证明这一点:
显示Model.AgreementsList.Count < Model.Filter.DisplayLastAgreementsCount ? Model.AgreementsList.Count : Model.Filter.DisplayLastAgreementsCount
@Model.AgreementsList.Count
我需要在cshtml文件中写什么?
我使用@
和{}
并没有找到解决方案。
感谢
答案 0 :(得分:3)
使用@()
(使用@{}
仅执行附带的代码,不会向响应流写入任何内容)
@(Model.AgreementsList.Count < Model.Filter.DisplayLastAgreementsCount ? Model.AgreementsList.Count : Model.Filter.DisplayLastAgreementsCount)
但是,不是在视图中执行此类操作,您可能最好使用ViewModel,甚至使用ViewBag
并从Controller分配此输出。
答案 1 :(得分:0)
使用@:
来编写字符串,使用@
来从模型中检索数据。