我在这条线上有一个异常,无法弄清楚为什么......也许其他人可以发现它
<img src="@{Model.Image != null ? Model.Image.FileName : "";}" width="200px" id="ImagePreview"/>
我得到的异常(exception)是:
error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
最佳答案
您需要使用表达式 (
显式 )
该表达式的代码块样式:
<img src="@(Model.Image != null ? Model.Image.FileName : "")" width="200px" id="ImagePreview"/>
见gu's post
关于asp.net-mvc-3 - Razor 内联if语句不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6206490/