Hi Team,
Need to check the files in given location and file names are added to list and those details need to show in modal popup with download and delete option.
I had tried with partialview but no luck to display in modal popup in MVC.
In controller Action
Tickets doc = new Tickets();
List<Tickets> doclist = new List<Tickets>();
if (dtDocs != null)
{
DataTable dtFiltereddocs = dtDocs.AsEnumerable().CopyToDataTable();
for (int i = 0; i < dtFiltereddocs.Rows.Count; i++)
{
Tickets uobj = new Tickets();
uobj.List = (dtFiltereddocs.Rows[i]["List"].ToString());
uobj.Path = (dtFiltereddocs.Rows[i]["Path"].ToString());
doclist.Add(uobj);
}
}
doc.Ticketinfo = doclist;
Session["DOCUpload"] = doc;
ViewBag.DOCUpload = doc;
return PartialView("ModalPopUp", doc);
In View:
function GetModalPopUp() {
var url = '@Url.Action("ModalPopUp", "TicketStatus")';
var table = document.getElementById("tblStatus");
var rows = table.rows;
for (var i = 0; i < rows.length; i++) {
rows[i].onclick = function () {
if (this.parentNode.nodeName == 'THEAD') {
return;
}
var cells = this.cells; //cells collection
var ticketNumber = (cells[1].innerHTML).replace(/<\/?span[^>]*>/g, "");
// alert(ticketNumber);
$.ajax({
type: 'POST',
url: "/TicketStatus/ModalPopUp",
data: { "ticketNumber": ticketNumber },
//contentType: "application/json; charset=utf-8",
//datatype: "json",
success: function (data) {
alert(data);
$('#exampleModal').html(data);
//$('#myModal').modal(options);
$('#myModal').modal('show');
}
, error: function (data) {
// alert(JSON.stringify(data));
}
});
}
}
}
In PartialView:
<div id="exampleModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body ">
<div id="popup">
<table id="tblDOC" class="table table-striped table-bordered table-hover" border="1" style="display:compact;" width="100%" cellspacing="0">
<thead>
<tr>
<th>Download</th>
<th>File Name</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
@if (Model.Ticketinfo.Count > 0)
{
foreach (var item in Model.Ticketinfo)
{
<tr>
<td>@Html.ActionLink("Download", "DownloadFile", new { fileName = @item.Path })</td>
<td><span>@item.List</span></td>
<td>@Html.ActionLink("Delete", "DeleteFile", new { fileName = @item.Path })</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="submitModal">Submit</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Kindly let me know what thing i missed.
Thanks in Advance.