我正在使用这样的代码进行文件上传。单击编辑按钮后,事件将触发到ashx页面。并且还从form.get方法中读取值。但我无法获得文件上传的路径。请帮我搞定。
jQuery("#grid").jqGrid({
url:'handler.ashx',
datatype: 'json',
mtype: 'GET',
colNames:['Seriel Number', 'Script Name', 'Script Location','Host Url','Protocol','Rampup Time','No of Users','Loop','Delay'],
colModel:[
{name:'sr_no',index:'sr_no', width:55,editable:false,editoptions:{readonly:true,size:10},hidden:true},
{name:'script_name',index:'script_name', width:100,editable:true, editrules:{required:false}, editoptions:{size:10, maxlength: 15}},
{name:'script_loc',index:'script_loc', width:100,editable:true, editrules:{required:false},edittype: 'file', editoptions:{enctype: "multipart/form-data"}},
{name:'host_url',index:'host_url', width:100,editable:true, editrules:{required:true}, editoptions:{ size:10, maxlength: 25}},
{name:'protocol',index:'protocol', width:100,editable:true, editrules:{required:true}, editoptions:{size:10, maxlength: 10}},
{name:'rampup_time',index:'rampup_time', width:100,editable:true, editrules:{required:true}, editoptions:{defaultValue: '0',size:2, maxlength: 4}},
{name:'noof_users',index:'noof_users', width:100,editable:true, editrules:{required:false}, editoptions:{size:4, maxlength: 8}},
{name:'loops',index:'loops', width:100,editable:true, editrules:{required:true}, editoptions:{defaultValue: '1' ,size:1, maxlength: 2}},
{name:'delay',index:'delay', width:100,editable:true, editrules:{required:true}, editoptions:{defaultValue: '0',size:1, maxlength: 4}}
],
postData: {
},
rowNum:20,
rowList:[20,40,60],
height: 200,
autowidth: true,
rownumbers: true,
pager: '#pager',
sortname: 'sr_no',
viewrecords: true,
sortorder: "asc",
caption:"Users",
emptyrecords: "Empty records",
loadonce: false,
loadComplete: function() {
},
})
答案 0 :(得分:0)
以下是我在代码中使用jqgrid的方法。使用此代码作为参考。我不说这是精确的colution但它可能对你有用。 在我的jqgrid脚本中,我已经使用param指定了url作为url:'controller.aspx?p = load'
jQuery("#jQGridDemo").jqGrid({
url: 'controller.aspx?p=load',
datatype: 'json',
mtype: 'POST',
colNames: ['Job Order #', 'Part #', 'Operation #' ...],
colModel: [...]
....
....
});
在我的controller.aspx页面中:
protected void Page_Load(object sender, EventArgs e)
{
Response.AddHeader("Content-type", "text/javascript");
if (Request.Params["p"].Equals("load"))
{
bool success = true;
OrderEntity[] arrReturn = Order.getOrderArray(0, -1);
int arry_size = arrReturn.Length;
string data = JsonConvert.SerializeObject(arrReturn);
string ret = "{data:" + data + ",\n";
ret += "recordType : 'object'}";
if (data == null)
{
success = false;
Response.Write("0");
}
if (success == true)
{
Response.Write(data);
}
}
}
在jqgrid-handler example handler with jqgrid
中引用此代码