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

asp.net-mvc-3 – mvc3剃刀条件包装器div

发布时间:2020-12-15 18:50:23 所属栏目:asp.Net 来源:网络整理
导读:什么是最好的方式来处理这样的东西: 剃刀代码: @if(!disableRowDiv){ div class="row"}divsome content here/div@if(!disableRowDiv){ /div} 所以Razor引擎不会产生这个错误: 解析器错误消息: The if block is missing a closing “}” character. Make
什么是最好的方式来处理这样的东西:

剃刀代码:

@if(!disableRowDiv)
{
    <div class="row">
}

<div>some content here</div>

@if(!disableRowDiv)
{
    </div>
}

所以Razor引擎不会产生这个错误:

解析器错误消息:

The if block is missing a closing “}” character. Make sure you have a matching “}” character for all the “{” characters within this block,and that none of the “}” characters are being interpreted as markup.

解决方法

这应该工作
@if(!disableRowDiv)
{
    @:<div class="row">
}
<div>some content here</div>
@if(!disableRowDiv)
{
    @:</div>
}

(编辑:李大同)

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

    推荐文章
      热点阅读