سلام به همه
میخوام اسم رکورد قبل از حذف به کاربر نمایش داه بشه، دوستان نمیدونم کجای کار میلنگه ...
اسم رکورد نمایش داده نمیشه که هیچ ... بدنه modal که توی partial view هست هم نمایش داده نمیشه!!!
فکر کنم اون کد جی ک.وئری مشکل داره
sFuUe.png
این اکشن حذف :
public IActionResult DelPlatform(int? id)
{
if (id == null)
{
return NotFound();
}
PR_Platform platformModel = _Iunit.PlatformsRepository.GenGetById(id);
if (platformModel == null)
{
return NotFound();
}
return View(platformModel);
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult DelPlatform(int id)
{
_Iunit.PlatformsRepository.GenDeleteById(id);
return RedirectToAction(nameof(PlatformList));
}
این دکمه حذف توی لیست :
<a asp-controller="Platform" asp-action="DelPlatform" asp-route-id="@item.PlatformId"
class="btn btn-danger btn-sm waves-effect waves-light" data-toggle="modal" data-target="#delete-modal">
<i class="mdi mdi-delete" data-toggle="tooltip" data-placement="top" title="حذف"></i></a>
این اسکریپت :
<script>
(function ($) {
function Delete() {
var $this = this;
function initilizeModel() {
$("#delete-modal").on('show.bs.modal', function (e) {
}).on('hidden.bs.modal', function (e) {
$(this).removeData('bs.modal');
});
}
$this.init = function () {
initilizeModel();
}
}
$(function () {
var self = new Delete();
self.init();
})
}(jQuery))
</script>
این modal توی پوشه shared :
<div class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" id="delete-modal" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header text-danger">
<h5 class="modal-title mt-0 text-white"><strong>حذف از پایگاه داده</strong></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-footer mr-auto">
<button type="submit" class="btn btn-primary waves-effect waves-light">حذف شود</button>
</div>
</div>
</div>
اینم پارشیال ویو اکشن حذف :
@model PR_Platform
@{
Layout = null;
}
<form asp-controller="Platform" asp-action="DelPlatform" method="post">
<div class="modal-body" id="delete-modal">
<p><strong>آیا از حذف <em>"@Model.PlatformName"</em> مطمئن هستید؟</strong></p>
<p class="mb-0"><small>@Model.PlatformName از پایگاه داده حذف خواهد شد</small></p>
</div>
</form>
ممنون از همه :-)