Telerik MVC Grid: The length of the string exceeds the value set on the maxJsonLength propery

by stuart 18. November 2011 21:56

Tags:

How to remove repeating commas in a string

by stuart 28. March 2011 14:15

string.Join(",", s.Split(',').Where(a => a != string.Empty).ToArray());

Tags:

How to call a WebMethod using JQuery passing Complex Types

by stuart 29. October 2010 12:52
Most of the examples I looked at just pass simple types to webmethod calls using JQuery. This blog entry demonstrates how to do this using a complex type: http://encosia.com/2009/04/07/using-complex-types-to-make-calling-services-less-complex/

var NewPerson = { };
 
NewPerson.FirstName = $("#FirstName").val();
NewPerson.LastName = $("#LastName").val();
NewPerson.Address = $("#Address").val();
NewPerson.City = $("#City").val();
NewPerson.State = $("#State").val();
NewPerson.Zip = $("#Zip").val();
 
// Create a data transfer object (DTO) with the proper structure.
var DTO = { 'NewPerson' : NewPerson };
 
$.ajax({
  type: "POST",
  contentType: "application/json; charset=utf-8",
  url: "PersonService.asmx/AddPerson",
  data: JSON.stringify(DTO),
  dataType: "json"
});

You'll need to include this Javascript library:

http://www.json.org/js.html

Tags:

Powered by BlogEngine.NET 2.5.0.6

 

About the author

I'm a MCSD.NET Software Developer

Tag cloud

Month List

Page List

Widget Twitter not found.

Root element is missing.X