Author Topic: Call webMethod with params from c# asp.net  (Read 4077 times)

manuela

  • Newbie
  • *
  • Posts: 1
    • View Profile
Call webMethod with params from c# asp.net
« on: April 14, 2016, 09:02:54 pm »
Hi
I'm using a c# asp.net web site.
to fill my grid remotly I need to call a webMethod. The webMethod has some params, such as the row numbers and the page index.
this is the method sample

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public static filteredTableItem GetIDataTmp(int pq_curpage, int pq_rpp)
        {     
            filteredTableItem ret = new filteredTableItem();
           [...]
           return ret;
         }

I'm calling it like this:

        var dataModel = {
            location: "remote",
            dataType: "JSON",
            method: "POST",
            curPage: 1,
            getData: function (dataJSON) {
                return { data: dataJSON.d.data };
            },
            beforeSend: function (jqXHR, settings) {
                jqXHR.setRequestHeader("Content-Type", "application/json");
            },
            getUrl: function () {
                return { url: "myPage.aspx/GetDataTmp", data: { pq_rpp: 1, pq_curpage: 20} };
            }
        };   

It gives me error, because it expects the parameters....
I have also tried with postData but I have the same problem.
What can I do?

Thanks
Manuela