Step :1 Put Below Code For Model Popup On Index Page
<div id="myModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModal-label">Error Details</h4>
</div>
<div id="myModalContent" style="padding:15px;"></div>
</div>
</div>
</div>
STEP : 2 Put Anchor Tag To Call Function Of Jquery
<a id='btnView' data-id='" + item.ID + "' class='btn btn-default'><span class='glyphicon glyphicon-eye-open' aria-hidden='true'></span></a>
Step : 3 Put JQuery Function To Call Method And Get Data On Anchor Tag Click
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).on("click", "a[id='btnView']", function (e) {
var ID = $(this).attr('data-id');
var options = { "backdrop": "static", keyboard: true };
$.ajax({
url: '@Url.Action("GetErrorDetails")',
type: "POST",
dataType: "html",
data: { ErrorID: ID },
success: function (data) {
//var message = data.Message;
//alert(data);
$('#myModalContent').html(data);
$('#myModal').modal('show');
}
});
});
$("#closbtn").click(function () {
$('#myModal').modal('hide');
});
<div id="myModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModal-label">Error Details</h4>
</div>
<div id="myModalContent" style="padding:15px;"></div>
</div>
</div>
</div>
STEP : 2 Put Anchor Tag To Call Function Of Jquery
<a id='btnView' data-id='" + item.ID + "' class='btn btn-default'><span class='glyphicon glyphicon-eye-open' aria-hidden='true'></span></a>
Step : 3 Put JQuery Function To Call Method And Get Data On Anchor Tag Click
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).on("click", "a[id='btnView']", function (e) {
var ID = $(this).attr('data-id');
var options = { "backdrop": "static", keyboard: true };
$.ajax({
url: '@Url.Action("GetErrorDetails")',
type: "POST",
dataType: "html",
data: { ErrorID: ID },
success: function (data) {
//var message = data.Message;
//alert(data);
$('#myModalContent').html(data);
$('#myModal').modal('show');
}
});
});
$("#closbtn").click(function () {
$('#myModal').modal('hide');
});
STEP : 4 Create Model Class
public class SiteErrorModel
{
public long ErrorID { get; set; }
public string ErrorCode { get; set; }
public string ExceptionMessage { get; set; }
public string ExceptionStackTrace { get; set; }
public string Source { get; set; }
public string IPAddress { get; set; }
public string Browser { get; set; }
public string Description { get; set; }
public string WebURL { get; set; }
public string ModifiedBY { get; set; }
public string ModifiedON { get; set; }
public string UserName { get; set; }
public Int64? TotalRows { get; set; }
}
STEP :5 Use Below Method in Controller
public ActionResult GetErrorDetails(string ErrorID)
{
var siteError = db.SiteErrors.Find(Convert.ToInt64(ErrorID));
SiteErrorModel siteErrorModel = new SiteErrorModel
{
ErrorID=siteError.ErrorID,
ErrorCode=siteError.ErrorCode,
ExceptionMessage=siteError.ExceptionMessage,
ExceptionStackTrace = siteError.ExceptionStackTrace,
IPAddress=siteError.IPAddress,
Browser=siteError.Browser,
Source = siteError.Source,
Description = siteError.Description
};
return PartialView("_SiteErrorPartial", siteErrorModel);
}
STEP 6: Create Partial View
@model OnlineShop.Models.SiteErrorModel
<div class="row">
<div class="col-md-12">
<b>IPAddress</b>
</div>
</div>
<div class="row">
<div class="col-md-12">
@Html.DisplayFor(model => model.IPAddress)
</div>
</div>
<div class="row">
<div class="col-md-12">
<b>Browser</b>
</div>
</div>
<div class="row">
<div class="col-md-12">
@Html.DisplayFor(model => model.Browser)
</div>
</div>
<div class="row">
<div class="col-md-12">
<b>ExceptionStackTrace</b>
</div>
</div>
<div class="row">
<div class="col-md-12">
@Html.DisplayFor(model => model.ExceptionStackTrace)
</div>
</div>
<div class="row">
<div class="col-md-12">
<b>Source</b>
</div>
</div>
<div class="row">
<div class="col-md-12">
@Html.DisplayFor(model => model.Source)
</div>
</div>
<div class="row">
<div class="col-md-12">
<b>Description</b>
</div>
</div>
<div class="row">
<div class="col-md-12">
@Html.DisplayFor(model => model.Description)
</div>
</div>
No comments:
Post a Comment