简体   繁体   English

如何在ASP.NET中的Kendo Web方法数据源中传递参数?

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

I have an asp.net application. 我有一个asp.net应用程序。 I am using kendo bullet charts. 我正在使用kendo子弹图表。 It is developed in .net framework 2.0 so wcf service is not working. 它是在.net Framework 2.0中开发的,因此wcf服务无法正常工作。 That is why I am using web methods for binding of remote data. 这就是为什么我使用Web方法绑定远程数据的原因。

I want to pass value of ac# variable in kendo web method data source url but it is not working. 我想在kendo Web方法数据源URL中传递ac#变量的值,但是它不起作用。

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. 您正在Kendo UI DataSource定义的错误位置定义data参数。 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: {
    //...
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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