这是我设置会话变量的页面之一,我将使用它来存储值
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");
}
这是我提取这些会话变量的页面:
公共部分类 MainBookingform : System.Web.UI.Page
{
static int numberOfBeachBookingInteger = 0;
static int numberOfBushBookingInteger = 0;
static int totalRevenueInteger = 0;
公共部分类 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;
}
}
}
}
但是,当我调试程序时,它不会将 1 添加到变量会话: beachBach 和 bushBach 并且有时它不会添加任何值..
请帮忙