单独的开始标签和结束在foreach()和if()中 [英] Separate opening tag and closing in foreach() and if()

查看:116
本文介绍了单独的开始标签和结束在foreach()和if()中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做单独的打开和关闭标签时遇到一些问题,遇到解析错误,我在mvc1-2中这样做,但是在mvc4中如何完成?

I'm having some problems with doing separate opening and closing tags, I get a parsing error, I done like this in mvc1-2 but how is this done in mvc4?

我正在执行foreach(),并且根据计数,我打开了div然后关闭了div

I'm doing a foreach() and depending on the count I'm gone open up a div and close a div

这是代码

 foreach (var d in Model.MenuDays)
 {
    if (d.Id == 1 || d.Id == 4)
    {
        <div class='row'>
    }

//code here

 @if (d.Id == 3)
 {
       </div>


    }
}

推荐答案

尝试一下,我不确定

@{
    @:<div>
}
@if(true)
{
   @:</div>
}

这篇关于单独的开始标签和结束在foreach()和if()中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆