与 asp.net 一起使用时未找到 Jqgrid 内联错误处理程序文件
Jqgrid Inline Error Handler file Not found while Using it with asp.net
我正在使用 Jqgrid 通过 asp.net 进行内联编辑,并使用 handler.ashx 文件存储来自网格的值。它在我的 VS 中工作得很好,但是当我发布并 运行 它在 iis 上时它会出错。
以下是jqgrid的代码
$("#grid-table-Labor").jqGrid({
url: 'LaborApproval.aspx/GetLaborData', //asp function to get all data from data base to grid
data: "{}",
datatype: 'json',
mtype: 'POST',
serializeGridData: function (postData) {
return JSON.stringify(postData);
},
ajaxGridOptions: { contentType: "application/json" },
loadonce: true,
colNames: [' ', 'Employee Code', 'Name', 'Contractor', 'DOJ', 'Police Verification', 'Gate Pass Valid Upto', 'Status', 'Remark'],
colModel: [
{
name: 'myac', index: 'myac', width: 80, fixed: true, sortable: false, resize: false, formatter: 'actions',
formatoptions: {
keys: true,
delbutton: false,
editOptions: {},
addOptions: {},
delOptions: {}
}
},
{ name: 'EMPCODE', index: 'EMPCODE', width: 108, key: true },
{ name: 'NAME', index: 'NAME', width: 140 },
{ name: 'CONTNAME', index: 'CONTNAME', width: 160 },
{ name: 'DOJ', index: 'DOJ', width: 70, formatter: 'date', formatoptions: { newformat: 'd-m-y' } },
{ name: 'POLICE_VRIFICATION', index: 'POLICE_VRIFICATION', width: 124 },
{ name: 'GatePassValidUpto', index: 'GatePassValidUpto', editable: true, sorttype: "date", unformat: pickDate },
{ name: 'Approve', index: 'Approve', width: 148, editable: true, edittype: "select", editoptions: { value: "True:Approve;False:Rejected" } },
{ name: 'REMARK', index: 'REMARK', width: 150, sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "2", cols: "10" } }
],
pager: '#grid-pager-Labor',
altRows: true,
//cacheUrlData: true,
//toppager: true,
rowNum: 10,
scrollOffset: 0, // to remove offset of scroll bar for imporved gui
rowList: [10, 50, 100, 200, 300, 500, 800, 1000, 1500],
//onSelectRow: editRow,
viewrecords: true,
emptyrecords: "Nothing to display",
//multiselect: true,
//multiboxonly: false,
gridview: true,
loadComplete: function () {
var table = this;
setTimeout(function () {
//styleCheckbox(table);
//updateActionIcons(table);
updatePagerIcons(table);
enableTooltips(table);
}, 0);
},
jsonReader: {
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.d.length; },
root: function (obj) { return obj.d; },
repeatitems: false,
id: "0"
},
editurl: 'Handler/JQGridHandler.ashx',
caption: 'Labor List',
shrinkToFit: true,
height: 'auto',
//autowidth: true,
xmlReader: {
root: "list",
row: "Response",
id: "cfgId",
repeatitems: false
},
beforeSelectRow: function (rowid, e) {
var iCol = $.jgrid.getCellIndex($(e.target).closest("td")[0]);
if (this.p.colModel[iCol].name === 'EMPCODE') {
var param = { param: rowid };
console.log(rowid);
$.ajax({
url: "LaborApproval.aspx/ShowMe",
data: JSON.stringify(param),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
var box = bootbox.dialog({
show: true,
message: data['d'],
title: "Labour Details",
buttons: {
ok: {
label: "OK",
className: "btn-primary",
callback: function() {
console.log('OK Button');
}
}
}
});
box.modal('show');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
var err = eval("(" + XMLHttpRequest.responseText + ")");
alert(err.Message)
// console.log("Ajax Error!");
}
});
return false;
}
}
});
下面是错误
[HttpException]: The file '/CMS/Web_Pages/HR_Pages/Handler/JQGridHandler.ashx' does not exist.
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
我只需要输入
editurl: '../../Handler/JQGridHandler.ashx',
之前 link
我正在使用 Jqgrid 通过 asp.net 进行内联编辑,并使用 handler.ashx 文件存储来自网格的值。它在我的 VS 中工作得很好,但是当我发布并 运行 它在 iis 上时它会出错。
以下是jqgrid的代码
$("#grid-table-Labor").jqGrid({
url: 'LaborApproval.aspx/GetLaborData', //asp function to get all data from data base to grid
data: "{}",
datatype: 'json',
mtype: 'POST',
serializeGridData: function (postData) {
return JSON.stringify(postData);
},
ajaxGridOptions: { contentType: "application/json" },
loadonce: true,
colNames: [' ', 'Employee Code', 'Name', 'Contractor', 'DOJ', 'Police Verification', 'Gate Pass Valid Upto', 'Status', 'Remark'],
colModel: [
{
name: 'myac', index: 'myac', width: 80, fixed: true, sortable: false, resize: false, formatter: 'actions',
formatoptions: {
keys: true,
delbutton: false,
editOptions: {},
addOptions: {},
delOptions: {}
}
},
{ name: 'EMPCODE', index: 'EMPCODE', width: 108, key: true },
{ name: 'NAME', index: 'NAME', width: 140 },
{ name: 'CONTNAME', index: 'CONTNAME', width: 160 },
{ name: 'DOJ', index: 'DOJ', width: 70, formatter: 'date', formatoptions: { newformat: 'd-m-y' } },
{ name: 'POLICE_VRIFICATION', index: 'POLICE_VRIFICATION', width: 124 },
{ name: 'GatePassValidUpto', index: 'GatePassValidUpto', editable: true, sorttype: "date", unformat: pickDate },
{ name: 'Approve', index: 'Approve', width: 148, editable: true, edittype: "select", editoptions: { value: "True:Approve;False:Rejected" } },
{ name: 'REMARK', index: 'REMARK', width: 150, sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "2", cols: "10" } }
],
pager: '#grid-pager-Labor',
altRows: true,
//cacheUrlData: true,
//toppager: true,
rowNum: 10,
scrollOffset: 0, // to remove offset of scroll bar for imporved gui
rowList: [10, 50, 100, 200, 300, 500, 800, 1000, 1500],
//onSelectRow: editRow,
viewrecords: true,
emptyrecords: "Nothing to display",
//multiselect: true,
//multiboxonly: false,
gridview: true,
loadComplete: function () {
var table = this;
setTimeout(function () {
//styleCheckbox(table);
//updateActionIcons(table);
updatePagerIcons(table);
enableTooltips(table);
}, 0);
},
jsonReader: {
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.d.length; },
root: function (obj) { return obj.d; },
repeatitems: false,
id: "0"
},
editurl: 'Handler/JQGridHandler.ashx',
caption: 'Labor List',
shrinkToFit: true,
height: 'auto',
//autowidth: true,
xmlReader: {
root: "list",
row: "Response",
id: "cfgId",
repeatitems: false
},
beforeSelectRow: function (rowid, e) {
var iCol = $.jgrid.getCellIndex($(e.target).closest("td")[0]);
if (this.p.colModel[iCol].name === 'EMPCODE') {
var param = { param: rowid };
console.log(rowid);
$.ajax({
url: "LaborApproval.aspx/ShowMe",
data: JSON.stringify(param),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
var box = bootbox.dialog({
show: true,
message: data['d'],
title: "Labour Details",
buttons: {
ok: {
label: "OK",
className: "btn-primary",
callback: function() {
console.log('OK Button');
}
}
}
});
box.modal('show');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
var err = eval("(" + XMLHttpRequest.responseText + ")");
alert(err.Message)
// console.log("Ajax Error!");
}
});
return false;
}
}
});
下面是错误
[HttpException]: The file '/CMS/Web_Pages/HR_Pages/Handler/JQGridHandler.ashx' does not exist.
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
我只需要输入
editurl: '../../Handler/JQGridHandler.ashx',
之前 link