MVC3剃刀有条件的包装DIV [英] mvc3 razor conditional wrapper div
本文介绍了MVC3剃刀有条件的包装DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是处理这样的事情最好的办法:
剃须刀code:
@if(!disableRowDiv)
{
< DIV CLASS =行>
}< DIV>此处的某些内容和LT; / DIV>@if(!disableRowDiv)
{
< / DIV>
}
这样的剃刀引擎不会产生这个错误:
分析器错误信息:
if块缺少结束}字符。确保你有一个匹配的}字符此块内的所有的{字符,并且没有任何的}字符正在PTED为标记间$ P $。
块引用>解决方案这应该工作
@if(!disableRowDiv)
{
@:其中,DIV CLASS =行>
}
< DIV>此处的某些内容和LT; / DIV>
@if(!disableRowDiv)
{
@:LT; / DIV>
}What's the best way to handle something like this:
Razor Code:
@if(!disableRowDiv) { <div class="row"> } <div>some content here</div> @if(!disableRowDiv) { </div> }
So that the Razor engine doesn't produce this error :
Parser Error Message:
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.
解决方案This should work
@if(!disableRowDiv) { @:<div class="row"> } <div>some content here</div> @if(!disableRowDiv) { @:</div> }
这篇关于MVC3剃刀有条件的包装DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文