use*_*448 12 asp.net razor asp.net-mvc-3
使用剃刀,您如何有条件地退出或结束或返回或打破局部视图?
@if (Model == null)
{
    return;
}
Dar*_*rov 11
不,你不在return视图中,你只是在主视图中不包含这样的部分:
@if (Model != null) {
    @Html.Partial("somePartial", Model)
}
或者如果您使用RenderPartial:
@if (Model != null) {
    @{Html.RenderPartial("somePartial", Model);}
}
反转if:
<p>html that I always want</p>
@if (Model != null)
{
      your html when model != null
}
| 归档时间: | 
 | 
| 查看次数: | 6105 次 | 
| 最近记录: |