Я хочу использовать загрузочную коробку для отображения подтверждающих сообщений. Однако я не знаю, как вызвать действие с двумя параметрами из файла javascript. Эти параметры меняются в зависимости от итерации l oop.
Вот l oop с точки зрения,
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Program.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.Time)
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.StartDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.EndDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.MaximumStudentNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.Club.Name)
</td>
<td>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#@item.Program.Id">
@StudentActivity.Resources.Language.Details
</button>
<!-- Modal -->
<div class="modal fade" id="@item.Program.Id" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h3 class="modal-title text-center" id="exampleModalLabel">@item.Program.Title</h3>
</div>
<div class="modal-body">
<table class="table table-bordered table-hover">
<tr class="danger">
<td class="row-center">@StudentActivity.Resources.Language.Time</td>
<td class="row-center">@item.Program.Time</td>
</tr>
<tr>
<td class="row-center">@StudentActivity.Resources.Language.StartDate</td>
<td class="row-center">@item.Program.StartDate</td>
</tr>
<tr class="danger">
<td class="row-center">@StudentActivity.Resources.Language.EndDate</td>
<td class="row-center">@item.Program.EndDate</td>
</tr>
<tr>
<td class="row-center">@StudentActivity.Resources.Language.MaximumStudentNumber</td>
<td class="row-center">@item.Program.MaximumStudentNumber</td>
</tr>
@if (item.Program.Description != null)
{
<tr class="danger">
<td class="row-center">@StudentActivity.Resources.Language.Description</td>
<td>@item.Program.Description</td>
</tr>
}
</table>
</div>
</div>
</div>
</div>
@Html.ActionLink(StudentActivity.Resources.Language.Delete_Program, "DeleteStuPrg", "Program", new { studentId = item.StudentId, programId = item.ProgramId },
new { @class = "btn btn-primary", onclick = "return confirm('Are you sure you want to Delete this program?')" })
</td>
</tr>
Действие Html .Action (@ Html .ActionLink (StudentActivity.Resources.Language.Delete_Program, "DeleteStuPrg", "Program", new {studentId = item.StudentId, programId = item.ProgramId}, new {@class = "btn btn-primary", onclick = «return verify (« Вы уверены, что хотите удалить эту программу? »)»}))
работает нормально, но я хочу, чтобы внутри одного из браузеров было сообщение о подтверждении загрузочной коробки.
Я заменил ссылку действия на
<button type="button" onclick="DeletePAlertBootBoxEn();" class="btn btn-default">
@StudentActivity.Resources.Language.Delete
Вот действие внутри контроллера,
public ActionResult DeleteStuPrg(String studentId, int programId, string language)
{
ChangingLanguageFunction(language);
var StuPrg = _context.StudentPrograms.Where
(s => s.StudentId == studentId)
.Single(p => p.ProgramId == programId);
_context.StudentPrograms.Remove(StuPrg);
_context.SaveChanges();
return RedirectToAction("StuPrograms", "Program", new { id = StuPrg.StudentId });
}
Вот это JavaScript,
function DeletePAlertBootBoxEn() {
event.preventDefault();
bootbox.dialog({
title: "Confitmation Message!",
message: "Are You Sure You Want to Delete This Program?", title: "Confirmation Message",
buttons: {
main: { label: '<i class="fa fa-times"></i> Cancel', callback: function () { return true; } },
success: { label: '<i class="fa fa-check"></i> Confirm', callback: function () { //I need to have the call here } }
}
}).find('.modal-content').css({ 'text-align': 'center' });
}
Я попробовал Url.action
без положительного результата. Я также попробовал это с windows.location.href
без каких-либо положительных результатов.
Любая помощь приветствуется.