私は次のメインビューを持っています:-
@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 要素である必要がありますか?
ありがとう