我有一个简单的 HTML,它根据topic.IsScheduled
的值(bool)变化:
如果为假:
+-------------------+-------------------+
| row-fluid |
+-------------------+-------------------+
| span6(something1) | span6(something2) |
+-------------------+-------------------+
如果真实:
+-------------------+-------------------+
| row-fluid |
+-------------------+-------------------+
| span6(something1) | span6(something3) |
+-------------------+-------------------+
| row-fluid |
+-------------------+-------------------+
| span6(something2) | span6(something4) |
+-------------------+-------------------+
剃须刀/cshtml:
<div class="row-fluid">
<div class="span6">
something1
</div>
@if (topic.IsScheduled){
<div class="span6">
something3
</div>
</div>
<div class="row-fluid">
}
<div class="span6">
something2
</div>
@if (topic.IsScheduled) {
<div class="span6">
something4
</div>
}
</div>
但是当我这样做时,运行项目时出现以下错误:
System.Web.HttpParseException (0x80004005): 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. at
我已经测试过,C# 给了我错误,因为div
s 没有在@if
语句内关闭,而不是因为缺少开/关括号。如果我在 if 中关闭它们,或者简单地用 if 评论整个 if @* *@
,那么它就可以工作。
如何配置为忽略HttpParse
甚至关闭它以停止解析我的 HTML?
是的,我可以创建 if/else,但是我会重复 HTML 和变量,因为解析器是愚蠢的,我想避免这种情况。