by stuart
18. November 2011 21:56
by stuart
28. March 2011 14:15
string.Join(",", s.Split(',').Where(a => a != string.Empty).ToArray());
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