|
asp .net mvc C# Class Persistance Postback
Here is the solution to persist data in a class in asp .net mvc C# on postback
public class FilterClass
{
public int PriceHigh { get; set; }
public int PriceLow { get; set; }
public String Category { get; set; }
public String State { get; set; }
public String City { get; set; }
public String Location { get; set; }
}
public FilterClass oFilterClass {
get
{
if (Session["FilterClass"] == null)
{
Session["FilterClass"] = new FilterClass() { Category = null, PriceLow = 0, PriceHigh = 10000 };
return (FilterClass)Session["FilterClass"];
}
else
{
return (FilterClass)Session["FilterClass"];
}
}
set
{
Session["FilterClass"] = value;
}
}
|