InsertionMode.ReplaceWith和InsertionMode.Replace之间的区别

时间:2018-08-28 13:01:25

标签: asp.net asp.net-mvc asp.net-mvc-5

我有这个观点:

@using HelperMethods.Models
@model string
@{
    ViewBag.Title = "GetPeople";
    Layout = "/Views/Shared/_Layout.cshtml";
    AjaxOptions ajaxOpts = new AjaxOptions
    {
        UpdateTargetId = "tableBody",
        InsertionMode = InsertionMode.ReplaceWith
    };
}
<h2>Get People</h2>
<table>
    <thead><tr><th>First</th><th>Last</th><th>Role</th></tr></thead>
    <tbody id="tableBody">
        @Html.Action("GetPeopleData", new { selectedRole = Model })
    </tbody>
</table>
@using (Ajax.BeginForm("GetPeopleData", ajaxOpts))
{
    <div>
        @Html.DropDownList("selectedRole", new SelectList(new[] { "All" }.Concat(Enum.GetNames(typeof(Role)))))
        <button type="submit">Submit</button>
    </div>
}

如果我使用ReplaceWith,根据this answer,它应替换<tbody>标记及其内容,但是在检查“开发人员”标签中的表时,无论使用哪个标记, Chrome浏览器,我看到<tbody>标签仍然存在。

0 个答案:

没有答案