简体   繁体   中英

How to pass parameters in kendo web method data source in asp.net?

I have an asp.net application. I am using kendo bullet charts. It is developed in .net framework 2.0 so wcf service is not working. That is why I am using web methods for binding of remote data.

I want to pass value of ac# variable in kendo web method data source url but it is not working.

Here is my code,

var month = "<%= month %>";

dataSource: {
  type: "json",
  transport: {
    read: {
      type: "POST",
      url: "Default.aspx/FetchCounts",
      contentType: 'application/json; charset=utf-8',
      datatype: "json"
    }
  },
  serverFiltering: false,
  serverSorting: false,
  schema: {
    //data: "d",
    data: month,
    model: {
      fields: {
        current: { type: "string" },
        target: { type: "string" }
      }
    }
  }
},

which is not working.

I do not know how to make it work.

You are defining the data parameter in the wrong location of the Kendo UI DataSource definition. Reference . This is how it should be set up:

dataSource: {
  type: 'json',
  transport: {
    read: {
      type: 'POST',
      url: 'Default.aspx/FetchCounts',
      contentType: 'application/json; charset=utf-8',
      datatype: 'json',
      data: function () {
        return { 
          month: month 
        };
      }
    }
  },
  serverFiltering: false,
  serverSorting: false,
  schema: {
    //...
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM