剃刀:其中,文本&GT;条件语句投掷误差范围内标签 [英] Razor: <text> tag within conditional statement throwing error
本文介绍了剃刀:其中,文本&GT;条件语句投掷误差范围内标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@if (Model.Property != null)
{
<text>
<div class="row">
</text>
Html.RenderPartial("~/Views/CustomView.cshtml", Model);
<text> (line throwing error)
</div>
</text>
}
错误:文本元素没有关闭所有元素都必须是自闭或有一个匹配的结束标记。
Error: "The "text" element was not closed. All elements must be either self-closing or have a matching end tag."
我很难理解为什么第二组&LT的;文本&GT;
标签返回了错误。任何帮助了解这将是AP preciated。
I struggle to understand why second set of <text>
tags is returning that error. Any help to understand it would be appreciated.
推荐答案
在剃刀,标签必须正确嵌套。 &LT;文本&GT;&LT; / DIV&GT;&LT; /文本方式&gt;
是不恰当的嵌套
In Razor, tags must be nested properly. <text></div></text>
is not proper nesting.
我觉得你的情况,你应该简单地删除所有&LT;文本&GT;
和&LT; /文本&GT;
标签:
I think in your case you simply should remove all the <text>
and </text>
tags:
@if (Model.Property != null)
{
<div class="row">
@Html.Partial("~/Views/InTimeTemplate/InputFormElements/ReadMore.cshtml", Model);
</div>
}
这是等同于:
@if (Model.Property != null)
{
<div class="row">
@{
Html.RenderPartial("~/Views/InTimeTemplate/InputFormElements/ReadMore.cshtml", Model);
}
</div>
}
-
部分
将返回结果,将呈现感谢@
-
的RenderPartial
将直接呈现,但您需要引入与A C#块@ {
...}
Partial
will return the result, which will be rendered thanks to the@
RenderPartial
will render it directly, but you need to introduce a C# block with@{
...}
这篇关于剃刀:其中,文本&GT;条件语句投掷误差范围内标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文