Session["CartSubTotal"] = Convert.ToDouble(Session["CartSubTotal"]) + Price;
I get an error like this:
c:\inetpub\wwwroot\aaagolfballs\ShoppingCart.aspx.cs(235): An object reference is required for the nonstatic field, method, or property 'System.Web.UI.Page.Session'
What is a guy to do?If Session["CartSubTotal"] has not been set, that is the error you get.
Check if Session["CartSubTotal"]==null, if so, just set it equal to price rather than trying to add in the existing value of the session variable...
It was null, but I put into the global.asax:
protected void Session_Start(Object sender, EventArgs e)
{
Session["CartSubTotal"] = 0;
}
I still get the same error.
I've got it. For those with the same error, here is how I fixed it. I used these variables in the static method:
System.Web.HttpContext.Current.Session
System.Web.HttpContext.Current.Server
Thanks to all.
0 comments:
Post a Comment