我有以下主要观点:-
@using (Ajax.BeginForm("AssignCustomer", "Firewall", new AjaxOptions
{
InsertionMode = InsertionMode.InsertAfter,
UpdateTargetId = ??????????,
LoadingElementId = "progress",
HttpMethod= "POST",
OnSuccess="submitform"
}))
{
@Html.ValidationSummary(true)
@Html.AntiForgeryToken()
@Html.HiddenFor(model=>model.FirewallCustomer.ID)
<div>
<span class="f">Customer Name</span>
@Html.TextBoxFor(model => model.FirewallCustomer.CustomerName, new { data_autocomplete_source = Url.Action("CustomerAutoComplete", "Firewall") })
@Html.ValidationMessageFor(model => model.FirewallCustomer.CustomerName)
</div>
<input type="submit" value="Save" class="btn btn-primary"/>
}
<p><img src="~/Content/Ajax-loader-bar.gif" class="loadingimage" id="progress" /></p>
<table id ="myTable" class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th class="f"> Customer Name </th>
<th></th>
</tr></thead>
<tbody id="tableBody">
@foreach(var info in Model.Firewall.FirewallCustomers.OrderBy(a=>a.CustomerName)){
<tr id= "@info.CustomerName.Replace(" ", string.Empty)">
<td> @Html.ActionLink(info.CustomerName, "Index", "Customer", new {searchTerm=info.CustomerName},null)</td>
<td> @Ajax.ActionLink("Delete",
"DeleteCustomerFirewall", "Firewall",
new { firewallid = info.ID, customername = info.CustomerName},
new AjaxOptions
{ Confirm = "Are You sure You want to delete " + info.CustomerName,
HttpMethod = "Post",
OnSuccess = "deletionconfirmation",
OnFailure = "deletionerror"
})</td>
</tr>
}
</tbody>
当点击 ajax.beginform 我需要插入以下部分视图作为表格的第一行:-
@model TMS.Models.FirewallCustomer
<tr id= "@Model.CustomerName.Replace(" ", string.Empty)">
<td> @Html.ActionLink(Model.CustomerName, "Index", "Customer", new {searchTerm=Model.CustomerName},null)</td>
<td> @Ajax.ActionLink("Delete",
"DeleteCustomerFirewall", "Firewall",
new { firewallid = Model.ID, customername = Model.CustomerName},
new AjaxOptions
{ Confirm = "Are You sure You want to delete " + Model.CustomerName,
HttpMethod = "Post",
OnSuccess = "deletionconfirmation",
OnFailure = "deletionerror"
})</td>
</tr>
谁能建议我应该在 Ajax.BeginForm 的 UpdateTargerID 中添加什么;这个 id 应该是表 ID (id="myTable") 还是 Tbody ID (id="tableBody") 或另一个 DOM 元素?
谢谢