Data not displaying in mobile listview when working with asmx webservice

4 posts, 0 answers
  1. Shree
    Shree avatar
    4 posts
    Member since:
    Apr 2012

    Posted 18 May 2012 Link to this post

    HI,
    I am trying to display json data in mobile listview which is returned by asmx webservice. The code for the webservice is:
    //Employee class
    public class Employee
        {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Company { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
        public string Country { get; set; }
    }
     [WebService(Namespace = "http://viper.nl")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]   
        [System.Web.Script.Services.ScriptService]
        public class ViperServices : System.Web.Services.WebService
        {
    [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
            public string TestJSON()
            {
                Employee[] e = new Employee[2];
                e[0] = new Employee();
               
     e[0].ID="1001";
       e[0].Name = "Ajay Singh";
                e[0].Company = "Birlasoft Ltd.";
                e[0].Address = "LosAngeles California";
                e[0].Phone = "1204675";
                e[0].Country = "US";             
                e[1] = new Employee(); 
        e[1].ID="1001";  
                e[1].Name = "Ajay Singh";
                e[1].Company = "Birlasoft Ltd.";
                e[1].Address = "D-195 Sector Noida";
                e[1].Phone = "1204675";
                e[1].Country = "India";
                return new JavaScriptSerializer().Serialize(e);
            }
      
        }

    Code how i tried to use the service and display in mobile list view:
     <script type="text/javascript">
             function EmployeeInit() {
                 var ds = new kendo.data.DataSource({
                     schema:{
                        data:"d",
                        model:{
                            id:"ID",
                            fields: {
                                ID:{type:"number"},
                                Name:{type:"string"},
                                }
                            },
                     transport: {
                         read: {
                             type: "POST",
                             url: "../Services/ViperServices.asmx/TestJSON",                      
                             ContentType: "application/json",
                             dataType: "json"
                         }
                     }
                 });           

             $("#EmployeeList").kendoMobileListView({
                dataSource: ds,
                template: "#:Name#"
            });
            }
            </script>

    //initialize list view
    <div data-role="view"  data-init="EmployeeInit " >     
               <ul id="EmployeeList">              
                </ul>        
        </div>


    I can see the json data if i invoke the service in brower from visual studio environment. But when i try to display in mobile listview, no data is displaying. 

    Can anyone tell me what mistake i made or can you provide me a working example on my scenario?

    Thanks,
    Shree, 
  2. Rajinder
    Rajinder avatar
    4 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    Hi Try like this
     $.ajax({
                    type: "Post",
                    url: "http://localhost:2223/Services/b2bService.asmx/checkAuthentication",
                    contentType: "application/json; charset=utf-8",
                    dataType: "Json",
                    data: '{ userName:"' + uName + '", password:"' + pass + '" }',
                    success: function (data) {
                        if (data.d) {
                            window.location = "subcategories.htm"
                      
                        }
                        else {
                            alert("Info:Invalid Authentication");
                        }
                    },
                    complete: function (data) {
                    },
                    error: function (result) {
                        alert(result.status + ' ' + result.statusText);
                    }
                });
    ------------------------------------------------------------------------------------------------
    <WebMethod()> _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
        Public Function checkAuthentication(ByVal userName As String, ByVal password As String) As Boolean
            If userName.Equals("1") AndAlso password.Equals("1") Then
                Return True
            Else
                Return False
            End If
        End Function

  3. Kendo UI is VS 2017 Ready
  4. Ashraf Syed
    Ashraf Syed  avatar
    1 posts
    Member since:
    Jul 2009

    Posted 25 Apr 2013 Link to this post

    Hi

    I  want access asp.net  web services in kendo mobile listview and i am new i have no idea how to get consume asp.net web services in  kendo mobile listview .I have created web services and returning value in string like this .

    {name: "RON"},{name: "Tom "},{name: "Tom"},{name: "Mary"}

    and i want show this value in   kendo mobile listview how it possible . This is my service .

    [WebMethod]
            public string   EmployeeList()
            {
              
                string abc = null;
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                SqlCommand cmd = new SqlCommand("select  Firstname from employee where branchid=@branchid", connection.getConn());
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@branchid", 9);
              
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                sda.Fill(ds);
                for( int i=0;i<ds.Tables[0].Rows.Count ;i++)
                {
                  //{name: "Sashimi salad", letter: "S" }
                    if (i == 0)
                    {
                        abc ="{name: "+'"'+ ds.Tables[0].Rows[i]["firstname"].ToString()+'"'+"}";
                    }
                    else
                    {
                        abc = abc +"," +"{name: " + '"' + ds.Tables[0].Rows[i]["firstname"].ToString() + '"' + "}";
                    }
                }
                return abc;         
            }
            //-------------
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 30 Apr 2013 Link to this post

    Hello,

    Basically implementations how to bind the dataSource (which is core transporting feature) with the different ASP.NET webforms technologies is covered in this GitHub repository:

    https://github.com/telerik/kendo-examples-asp-net


    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready