我正在使用asp.net。使用jTable,如果我将listaction放到某个页面(并在pageload中添加代码),它工作正常。如果我将webmethod添加到同一页面的代码后面的listaction代码中,那么获取
HttpContext.Current.Request [“frmdate”] = null
HTML代码
<div id="dSaleBillContainer" style="padding-top: 115px;"></div>
jTable代码
$('#dSaleBillContainer').jtable({
title: 'Sale Bills (User : <label id="user"></label>)',
paging: true,
pageSize: 10,
pageSizes: [10, 25, 50, 75],
sorting: true,
defaultSorting: 'S01F01 DESC',
selecting: true, //Enable selecting
multiselect: true, //Allow multiple selecting
selectingCheckboxes: true, //Show checkboxes on first column
selectOnRowClick: false,
openChildAsAccordion: true,
actions: {
listAction: 'dSaleBills.aspx/List'
//listAction: 'GetSalesBill.aspx?Mode=List' - this way working perfect with same code which is calling another page and issue is with same page code behind webmethod
},
.......
});
我如何填充数据,实际上这种方法是否正常工作
$('#btnLoad').click(function (e) {
debugger;
e.preventDefault();
$('#dSaleBillContainer').jtable('load', {
user: $('#ddlsbUsers').val(),
frmdate: $('#<%=txtFrmDate.ClientID %>').val(),
todate: $('#<%=txtToDate.ClientID %>').val(),
route: $('#ddlRoute').val() == "0" ? $('#ddlRoute').val() : $('#ddlRoute option:selected').text(),
searchText: $('#<%= txtSearchText.ClientID %>').val()
});
var ddlsbUsers = $("[id*=ddlsbUsers]");
$("#user").html(ddlsbUsers.find("option:selected").text());
});
//Load all records when page is first shown
$('#btnLoad').click();
webmethod代码
[System.Web.Services.WebMethod]
public static String List()
{
string Result;
string a = HttpContext.Current.Request["frmdate"];
string frmdate = HttpContext.Current.Request["frmdate"].ToString();
}
这是什么解决方案?
有没有更好的解决方案呢?答案对我很有帮助.........