Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

how to pass a datetime value to a webmethod asmx using -',json,asmx,webservice-client'

how to pass a datetime value to a webmethod asmx  using -',json,asmx,webservice-client'

I have a WebMethod with a parameter defined as DateTime. When I call that

webservice, I get this error:

  depth) at
  depth) at
  depth) at
  input, Int32 depthLimit,
  JavaScriptSerializer serializer) at
  serializer, String input, Type type,
  Int32 depthLimit) at
  input) at
  context, JavaScriptSerializer
  serializer) at
  methodData, HttpContext context) at
  context, WebServiceMethodData

This is my WebService:

/// <summary>
/// Summary description for AgendamentoService
/// </summary>
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AgendamentoService : System.Web.Services.WebService

    public AgendamentoService()

        //Uncomment the following line if using designed components

    public CompromissoWekCalendarVO[] GetCompromissos(int id_pessoa, DateTime start, DateTime end)
        bo.CompromissoBO compBO = new bo.CompromissoBO();
        return compBO.Get(id_pessoa,start, end).ToArray();


And here, my client side code:

 var params =  '{id_pessoa: "' + id_pessoa + '", start:/Date('+ start.getTime()+')/, end:/Date(' + end.getTime()+')/}';
                             type: "POST",  
                             dataType: "json",
                             contentType: "application/json; charset=utf-8",  
                             url: '<%= this.ResolveClientUrl("~/services/misc/AgendamentoService.asmx/GetCompromissos") %>',  
                             data: params,  
                             success: function (json) {  

                                if ($.isArray(json.d)) {
                                  $.each(json.d, function(key, value) {
                                    value.start = getJsonDate(value.start);
                                    value.end = getJsonDate(value.end);



Where 'start' and 'end' time are two javascript 'Date' objects.

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Government Jobs Opening