我遇到了问题,我真的很困惑。
我的标记很简单:
@foreach (var item in Model.Items)
{
<a class="mapIconUnit" id="pinDelete-@item.PinGuid.ToString()">
@Url.Action("DeletePin") <!-- testing purposes -->
@(Ajax.ActionLink("x", "DeletePin", MapAdministrationController.Routes.DeletePin(item.PinGuid), new AjaxOptions()
{
OnSuccess = "onMapPinDeleted",
Confirm = Resources.Resource.msg_GenericDeleteConfirmationQuestion
}
))
</a>
}
现在我期望从中得到的是:
<a class="mapIconUnit" id="...">
... rendered url
<a href="..." etc>x</a>
</a>
但我得到的是:
<a class="mapIconUnit" id="...">
... rendered url
</a>
<a href="..." etc>x</a>
我在这里做错了什么?标记太简单了,导致这样的事情是错误的吗?
答案 0 :(得分:1)
将锚元素嵌套在另一个锚元素中是非法的,可以在W3C规范中找到更多信息:http://www.w3.org/TR/html401/struct/links.html#h-12.2.2
Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.
因此剃刀或webbrowser正确渲染元素(即将它们放在一起)。