剃刀语法不符合我的预期 [英] Razor Syntax Not working the way I expected
本文介绍了剃刀语法不符合我的预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的剃须刀语法有问题
给出一个Parsor错误,指出 foreach块缺少结束符}"
gives a Parsor error saying that The foreach block is missing a closing "}" character
<ul>
@{var client = "null";}
@foreach (var instance in Model)
{
if (instance.tbl_Policy.tbl_Client.txt_clientName != client)
{
client = instance.tbl_Policy.tbl_Client.txt_clientName;
</ul><h1>@client</h1>
<ul>
}
<li>
@instance.tbl_Policy.txt_policyNumber -
Assigned to : @instance.aspnet_Membership.aspnet_User.UserName
@instance.ATLCheckType.Question
<button type="button" rel="<%:instance.ATLCheckInstanceId.ToString()%>">DelFiled</button>
<button type="button" rel="<%:instance.ATLCheckInstanceId.ToString()%>">DelLineItem</button>
</li>
}
</ul>
推荐答案
Razor无法处理代码块中不平衡的HTML标记.
Razor cannot handle imbalanced HTML tags in code blocks.
更改您的if
块,以将不平衡标签视为纯文本:
Change your if
block to treat the imbalanced tags as plain text:
if (instance.tbl_Policy.tbl_Client.txt_clientName != client)
{
client = instance.tbl_Policy.tbl_Client.txt_clientName;
@:</ul><h1>@client</h1>
@:<ul>
}
这篇关于剃刀语法不符合我的预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文