Send the object through pagemethods and access from server side
Send the parameter through object in asp.net:-
PageMethods is used to send the values from the client side (javascript,jquery) to server side program like in asp.net (aspx.cs) page. If we want to send more than 30 parameters then it will reduce the speed and may we have chance to confusion, so we can convert all that 30 parameters to objects and pass a single objects and receive from the server side and access.
For Example:-
1.Client Side
2.Sever Side
Advertisement
Screen shots:-
PageMethods is used to send the values from the client side (javascript,jquery) to server side program like in asp.net (aspx.cs) page. If we want to send more than 30 parameters then it will reduce the speed and may we have chance to confusion, so we can convert all that 30 parameters to objects and pass a single objects and receive from the server side and access.
For Example:-
1.Client Side
var obj = new Object();
obj.JobTitleID = 30;
obj.Month = 1;
obj.Year = 2014;
obj.Name="Ajay";
obj.Mark=988;
PageMethods.sendVal(obj);
obj.JobTitleID = 30;
obj.Month = 1;
obj.Year = 2014;
obj.Name="Ajay";
obj.Mark=988;
PageMethods.sendVal(obj);
2.Sever Side
[WebMethod]
public static void selectAssetName(object obj)
{
JavaScriptSerializer JSobj = new JavaScriptSerializer();
listobj[0].JobTitleID;
listobj[0].Month;
listobj[0].Year;
listobj[0].Name;
listobj[0].Mark;
}
public class EquatedModel
{
public int JobTitleID { set; get; }
public int Month { set; get; }
public int Year { set; get; }
public string Name { set; get; }
public int Mark { set; get; }
}
public static void selectAssetName(object obj)
{
JavaScriptSerializer JSobj = new JavaScriptSerializer();
List<EquatedModel> listobj = JSobj.ConvertToType<List<EquatedModel>>(obj);
listobj[0].JobTitleID;
listobj[0].Month;
listobj[0].Year;
listobj[0].Name;
listobj[0].Mark;
}
public class EquatedModel
{
public int JobTitleID { set; get; }
public int Month { set; get; }
public int Year { set; get; }
public string Name { set; get; }
public int Mark { set; get; }
}
Advertisement
Screen shots:-
Post a Comment for "Send the object through pagemethods and access from server side"