Hi,
I have below code . Can delete part be called thry Partial View so i have to write it every Controller View. I want marked part to be called thru Partial View
@foreach (var item in Model.Locations) { <tr> <td> @Html.DisplayFor(model => item.Id) </td> <td> @Html.DisplayFor(model => item.Description) </td> <td> @if(item.IsActive) { <i class='fa fa-check' style="color:Highlight"></i> } else { <i class='fa fa-times' style="color:red"></i> } </td> <td> <a class='btn btn-primary btn-sm' id='btnEdit'><i class='fa fa-pencil'></i> Edit </a> @if (item.IsActive) { <a id="btnDelete" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#[email protected]" style='margin-left:5px'><i class='fa fa-trash'></i> Delete </a> } else { <a class='btn btn-danger btn-sm disabled' id='btnDelete' style='margin-left:5px'><i class='fa fa-trash'></i> Delete </a> }
@using (Html.BeginForm("DeleteLocation", "Location", new { id = item.Id }, FormMethod.Post, null)) { @Html.AntiForgeryToken() <div class="modal" tabindex="-1" role="dialog" id="[email protected]"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> @*<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>*@ <h4 class="modal-danger">Delete Confirmation</h4> </div> <div class="modal-body"> <p>Are you sure you want to delete this record ?</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-danger">Delete</button> </div> </div> </div> </div> } </td> </tr> }
Thanks