Monday, 26 August 2013

Session Variables error

Session Variables error

this is one of my page where i set up my session variable which I will use
to store value
protected void confirmImageButton_Click(object sender, ImageClickEventArgs
e) { Session["confirmBooking"] = "confirm"; Session["totalCost"] =
toPayTextBox.Text;
// If bachRadioButtonList SelectedValue != "Beach bach",
// clear session variable, else set value to "Beach bach"
Session["beachBach"] = (bachRadioButtonList.SelectedValue != "Beach
bach");
// If bachRadioButtonList SelectedValue != "Bush bach",
// clear session variable, else set value to "Bush bach"
Session["bushBach"] = (bachRadioButtonList.SelectedValue != "Bush bach");
Response.Redirect("MainBookingform.aspx");
}
and this is the page where I pull out those session variables:
public partial class MainBookingform : System.Web.UI.Page
{
static int numberOfBeachBookingInteger = 0;
static int numberOfBushBookingInteger = 0;
static int totalRevenueInteger = 0;
public partial class MainBookingform : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
beachBachLabel.Text = numberOfBeachBookingInteger.ToString();
bushBachLabel.Text = numberOfBushBookingInteger.ToString();
if ((Session["bushBach"] != null) && (Session["beachBach"] != null))
{
if (Session["beachBach"] != "confirm")
{
numberOfBeachBookingInteger += 1;
}
if (Session["bushBach"] != "confirm")
{
numberOfBushBookingInteger += 1;
}
}
}
}
however, when I debug the program, it it doesn not add 1 to both the
variable session: beachBach and bushBach and sometime it wont add any
values..
please help

No comments:

Post a Comment