Pass C# object to webmthod through ajax
Ajax is frequently used in ASP.NET to pass data from javascript to c# methods known as WebMethod in webforms. It is easy to pass common data like string or int values to webmethod through ajax. Sometimes we need to pass whole object of some C# class thorugh ajax to avoid sending and receiving large number of parameters. Lets take an example where we will send UserInfo object from ajax to webmethod. This is our class whose object will be sent through ajax public class UserInfo { public int UserId { get ; set ; } public string UserName { get ; set ; } public string Address { get ; set ; } } And here is webmthod in which we will receive the UserInfo object [System.Web.Services. WebMethod ] public static void GetUserInfo( UserInfo User) { //Your Code } And Here is our ajax method var objUser = new Object(); ...