ASP.NET MVC Web サイトに次のコードがあります。
@foreach (var item in Model.Comments.Where(c=>c.CommentId == Model.CurrentNode))
{
if(Model.Level == 0){
@Html.Raw("<li style=\"border:none;\">")
}
else
{
@Html.Raw("<li>")
}
このページにアクセスしようとすると、次の例外が発生します。
パーサー エラー メッセージ: 一致する開始タグのない終了タグ "li" が見つかりました。開始タグと終了タグのバランスは適切ですか?
さまざまなオプションを試しましたが、これを機能させることができません。
編集1:
@if (!Model.CurrentNode.HasValue)
{
@Html.Raw("<div class=\"comment-root\" id=\"comment-root\">")
@*hid911 Tells what voteKey to use for this section*@
<input pid="hidVoteKey" type="hidden" value="1" />
}
<ul class="commentList sub">
@foreach (var item in Model.Comments.Where(c=>c.CommentId == Model.CurrentNode))
{
if(Model.Level == 0){
<li style="border:none;">
}
else
{
<li>
}
@if(!item.Deleted)
{
<div class="commentBack">
@if (Request.IsAuthenticated && uFeed.Handlers.AccountHandler.UserContextInstance.Id != item.CreatedBy.Id)
{
@Html.Partial("VotePartial", item.VoteViewModel)
}
else
{
<div style="float:left; width: 30px; "> </div>
}
<div class ="floatLeft" style="width: 90%">
<div class="CommentHeader" id="commentHeader-@item.Id">
<p class="Timestamp dimText">
@Html.ActionLink(item.CreatedBy.Text, "User/" + item.CreatedBy.Text, "Post")
| @item.VoteBalance poäng |
@Html.GetDisplayDate(item.CreatedDate)
</p>
</div>
<div id="commenttext-@item.Id" class="commentText">
@item.Text
</div>
<div id="comment-@item.Id" class="CommentFooter">
@if (Request.IsAuthenticated)
{
<div class="floatLeft">
@Html.ActionLink("Svara", string.Empty, null, new { id= "respond-" + item.Id, href = "#comment", @class = "respond" })
</div>
}
@if (Request.IsAuthenticated && uFeed.Handlers.AccountHandler.UserContextInstance.Id ==item.CreatedBy.Id)
{
<div class="floatLeft" id="divremove-@item.Id">
- @Html.ActionLink("Editera", string.Empty, null, new { id= "edit-" + item.Id, href = "#comment", @class = "edit" })
- @Html.ActionLink("Ta bort", string.Empty, null, new { id="remove-"+item.Id, @class = "remove"})
</div>
<div class="floatLeft hidden" id="divconfirmremove-@item.Id"> - Ta bort?
@Html.ActionLink("Ja", string.Empty, null, new { id = "confirm-remove-yes-" + item.Id, @class = "confirm-remove-yes" })
/
@Html.ActionLink("Nej", string.Empty, null, new { id = "confirm-remove-no-" + item.Id, @class = "confirm-remove-no" })
</div>
}
@if(Model.Comments.Any(c=>c.CommentId == item.Id))
{
@Html.Raw(" - ")
@Html.ActionLink("Dölj kommentarer", string.Empty, null, new { id = "toggle-" + item.Id, Href = "#togglecomments", @class = "toggle active" })
}
<div style="clear:both;"></div>
</div>
</div>
<div style="clear:both;"></div>
</div>
}
else
{
<div class="commentBack">
<div style="float:left; width: 30px; height: 30px"> </div>
<div style="float:left">
<div class="commentText" ><i>[Borttagen]</i></div>
<div id="comment-@item.Id" class="CommentFooter">
@if(Request.IsAuthenticated)
{
<div class="floatLeft">
@Html.ActionLink("Svara", string.Empty, null, new { id= "respond-" + item.Id, href = "#comment", @class = "respond" })
</div>
}
@if(Model.Comments.Any(c=>c.CommentId == item.Id))
{
@Html.Raw(" - ")
@Html.ActionLink("Dölj kommentarer", string.Empty, null, new { id = "toggle-" + item.Id, Href = "#togglecomments", @class = "toggle active" })
}
</div>
</div>
<div style="clear:both;"></div>
</div>
}
<div id="comments-for-@item.Id" class="CommentContainer">
@Html.Partial("CommentPartial", new uFeed.Views.ViewModels.CommentTreeItemViewModel(item.Id, Model.Comments, Model.Level + 1))
</div>
<div style="clear:both;"></div>
</li>
}
</ul>