Passing parameter to web service

2 posts, 0 answers
  1. Jonah
    Jonah avatar
    29 posts
    Member since:
    Oct 2012

    Posted 23 Mar 2013 Link to this post

    I have a web service that works fine before I pass in any parameter. Once I change the service to take a parameter I return no data. I am fairly new to asmx web services but here is my code for my service as well as the call.

    [WebService(Namespace = "")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    public class WebService : System.Web.Services.WebService {

        public WebService () {

            //Uncomment the following line if using designed components 

        List<string> datax = new List<string>();
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public object GetAgent(string agentId)
          DataClassesDataContext dc = new DataClassesDataContext();
          var ag = from x in dc.Agents
                    select x;
          foreach (var item in ag)
            datax.Add(item.FirstName + " " + item.LastName);
          //JavaScriptSerializer jss = new JavaScriptSerializer();
          //retVal = jss.Serialize(ag);
          return datax;

        var deviceJDS = new{
          schema: {
            data: "d"  // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
          transport: {
            read: {
              contentType: "application/json; charset=utf-8",
              type: "POST",
              dataType: "json",
              url: "http://localhost:65205/WebService.asmx/GetAgent",
               data: {agentId: 2}


          dataSource: deviceJDS
        var app = new;

  2. Alexander Valchev
    Alexander Valchev avatar
    2894 posts

    Posted 26 Mar 2013 Link to this post

    Hello Jonah,

    I am afraid that your question is not directly related to the build-in functionality or features that our product offers and as such is out of the scope of the standard support service. Kendo DataSource uses standard jQuery Ajax requests to communicate with the server. If you are able to process parameters send with standard Ajax request, you should not have problems to send same data with the DataSource transport.

    Kind regards,
    Alexander Valchev
    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