加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 条件ASP.NET MVC剃刀部分

发布时间:2020-05-25 02:05:30 所属栏目:asp.Net 来源:互联网
导读:只有当某些属性(Model.ReadOnly)为false时,才想定义此部分。 @section toolbar { div class=tool div class=row @Html.ActionLink( Resources.Strings.Edit, Edit, Profile ) /div

只有当某些属性(Model.ReadOnly)为false时,才想定义此部分。

@section toolbar {
    <div class="tool">
        <div class="row">
            @Html.ActionLink( Resources.Strings.Edit,"Edit","Profile" )
        </div>
        <div class="row">
            @Html.ActionLink( Resources.Strings.Delete,"Delete","Profile" )
        </div>
    </div >
}

我试着把它放在@if(!Model.ReadOnly){}中,但它不起作用。

有没有办法做到这一点?

我不想定义一个空的部分(as @itsmatt suggests),我的页面的布局会改变部分是否被定义(使用IsSectionDefined(“toolbar”))。

解决方法

这应该工作。
@if (!Model.ReadOnly)
{
    <text>
    @section toolbar {

    }
    </text>
}

我从来没有说过会漂亮的

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读