Hi
In below code i want Delete Modal should be declared in Main Layout file & can be called in any View
<table class="table table-striped table-hover" id="tblLocation" style="width:100%">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Location.Id)
th>
<th>
@Html.DisplayNameFor(model => model.Location.Description)
th>
<th>
@Html.DisplayNameFor(model => model.Location.IsActive)
th>
<th>Actionth>
tr>
thead>
@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="#DeleteModal-@item.Id" 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="DeleteModal-@item.Id">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-danger">Delete Confirmationh4>
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">Cancelbutton>
<button type="submit" class="btn btn-danger">Deletebutton>
div>
div>
div>
div>
}
td>
tr>
}
table>
************************ Below part i want to be declared in Main Layout
<table class="table table-striped table-hover" id="tblLocation" style="width:100%">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Location.Id)
th>
<th>
@Html.DisplayNameFor(model => model.Location.Description)
th>
<th>
@Html.DisplayNameFor(model => model.Location.IsActive)
th>
<th>Actionth>
tr>
thead>
@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="#DeleteModal-@item.Id" 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="DeleteModal-@item.Id">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-danger">Delete Confirmationh4>
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">Cancelbutton>
<button type="submit" class="btn btn-danger">Deletebutton>
div>
div>
div>
div>
}
td>
tr>
}
table>
Thanks
Ramco RamcoPosted Jun 20, 2021, 4:13 PM
Delete Confirmation
Are you sure you want to delete this record ?
Sachin SinghPosted Jun 20, 2021, 1:47 PM