剑道 UI 网格不调用 ASP.NET Web 服务
Kendo UI Grid not calling ASP.NET web service
我刚开始使用剑道UI网格。 我正在尝试让它与 ASP.NET Web 服务一起工作。
这是我必须创建网格的 js:
$("#grid").kendoGrid({
pageable: true,
dataSource: {
serverPaging: true,
schema: { data: "d.Records", total: "d.total" },
pageSize: 10,
type: "json",
transport: {
read: {
url: "/services/Records.asmx/GetRecords",
dataType: "json",
type: "POST",
contentType: "application/json; charset-utf-8"
}
}
},
rowTemplate: kendo.template($("#kendoTmpl").html())
});
这是 Web 方法的代码(显然只是测试一下):
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function GetRecords() As RecordList
Dim x as List(Of Record) = New List(Of Record)
Dim total as Integer = 25
Dim skipVal as Integer = Convert.ToInt32(HttpContext.Current.Request.QueryString("skip"))
Dim takeVal as Integer = Convert.ToInt32(HttpContext.Current.Request.QueryString("take"))
For i as Integer to total
'Record class has ID and Detail properties
x.Add(new Record(i, "This is Record #" + i.ToString()))
Next
'RecordList has Total and Records properties
Return New RecordList(total, x)
End Sub
我还引用了该页面:
jquery.min.js //jQuery v1.9.1
kendo.all.min.js
kendo.web.min.js
我已经在网络方法中设置了断点,但它们永远不会被命中。 我错过了什么?
所以我现在让它工作了。 归咎于缺乏经验。
我不得不修改传输值和 Web 方法。 这是工作代码:
...
transport: {
read: {
url: "/services/Records.asmx/GetRecords",
type: "POST",
contentType: "application/json; charset=utf-8"
},
parameterMap: function(data) {
return JSON.stringify(data);
}
}
...
和网络方法:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function GetRecords(ByVal skip as Integer, ByVal take as Integer) As RecordList
Dim x as List(Of Record) = New List(Of Record)
Dim total as Integer = 25
For i as Integer to total
'Record class has ID and Detail properties
x.Add(new Record(i, "This is Record #" + i.ToString()))
Next
'RecordList has Total and Records properties
Return New RecordList(total, x.Skip(skip).Take(take).ToList())
End Sub
相关文章:
- 同一文本框中的验证程序CPF e CNPJ(ASP.NET web应用程序)
- 如何使用默认的网络摄像头拍摄照片并将其保存在我的c#.net web应用程序中
- WebMethod在ASP.Net Web角色(Web窗体)中不起作用
- 如何使用phonegap在android中调用asp.net Web服务
- asp.net web表单客户端验证始终回发
- Testing .NET Web API from JavaScript
- 是否可以将 ASP.NET Web 应用程序上载到 VMware 上的虚拟 2008 服务器上
- 用于.NET Web开发的MetaWidget
- ASP中的动态图像.NET Web应用程序
- 是否可以在没有视图状态和回发的情况下使用asp.net web表单
- 如何通过AngularJS$http从ASP.Net Web API 2获取访问令牌
- ASP.net web服务使用javascript发送命令
- 在ASP.Net web窗体/MVC中动态加载和添加字段
- 在ASP.NET Web API 2项目中设置Angular路由
- 如何将字符串数组从javascript传递到asp.net Web服务
- ASP.NET Web API 控制器更新行
- ASP.NET Web API 2 - 如何开机自检
- 如何将服务器端类型传递给 asp.net Web 表单以供 JavaScript 使用
- 如何在 ASP.NET Web 表单中填补服务器端和客户端之间的空白
- asp.net Web API 405 方法不允许、发布、自定义操作