Hello,
I was trying to bind a listview to an ASP.Net .asmx web service using KendoUI mobile. I referred the following link to achieve this. But it’s not working for me.
http://www.kendoui.com/forums/framework/data-source/consuming-a-net-json-web-service.aspx
Pasting my code snippet for more help. Please let me know whether I am in right direction or what’s wrong with my code. It’s urgent, please help me.
index.html:-
TestService.cs
Thanks.
I was trying to bind a listview to an ASP.Net .asmx web service using KendoUI mobile. I referred the following link to achieve this. But it’s not working for me.
http://www.kendoui.com/forums/framework/data-source/consuming-a-net-json-web-service.aspx
Pasting my code snippet for more help. Please let me know whether I am in right direction or what’s wrong with my code. It’s urgent, please help me.
index.html:-
<!DOCTYPE html>
<
html
>
<
head
>
<
title
></
title
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"
/>
<
meta
charset
=
"utf-8"
>
<
script
type
=
"text/javascript"
charset
=
"utf-8"
src
=
"cordova-2.1.0.js"
></
script
>
<
script
src
=
"js/jquery.min.js"
></
script
>
<
script
src
=
"js/kendo.mobile.min.js"
></
script
>
<
script
src
=
"js/console.js"
></
script
>
<
link
href
=
"styles/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"styles/kendo.mobile.all.min.css"
rel
=
"stylesheet"
/>
</
head
>
<
body
>
<
a
href
=
"../index.html"
>Back</
a
>
<
div
data-role
=
"view"
id
=
"flat"
data-init
=
"mobileListViewDataBindInitFlat"
data-title
=
"ListView"
data-layout
=
"databinding"
>
<
ul
id
=
"flat-listview"
></
ul
>
</
div
>
<
script
>
var flatData = new kendo.data.DataSource({
transport: {
read: {
contentType: "application/json",
type: "POST",
data: {
q: "html5"
}
}
}
});
function mobileListViewDataBindInitFlat() {
$("#flat-listview").kendoMobileListView({ dataSource: flatData });
}
</
script
>
<
script
>
window.kendoMobileApplication = new kendo.mobile.Application(document.body);
</
script
>
</
body
>
</
html
>
TestService.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Services;
using
System.Web.Script.Services;
using
Northwind_newModel;
[ScriptService]
public
class
TestService : System.Web.Services.WebService {
[WebMethod]
public
List<CustomerModel> GetCustomerData()
{
using
(var northwind =
new
Northwind_newEntities1())
{
return
northwind.Customers
.Select(p =>
new
CustomerModel
{
CompanyName = p.CompanyName
}).Take(5).ToList();
}
}
}
Thanks.