我试图从 1 开始生成一个唯一 ID,但数字保持不变。我正在尝试使用会话变量,所以它可以像 1、2、3、4 一样......
主页:
protected void calculateButton_Click(object sender, EventArgs e)
{
int bookingID = 0;
bookingID += 1;
bookingIDTextBox.Text = bookingID.ToString();
}
protected void confirmButton_Click(object sender, EventArgs e)
{
Session["confirmBooking"] = "confirm";
Session["bookingID"] = bookingIDTextBox.Text;
Response.Redirect("MainBookingForm.aspx");
}
第二页:
protected void newBookingButton_Click(object sender, EventArgs e)
{
string bookingRef = (string)(Session["bookingID"]);
Session["bookingRef"] = bookingRef;
Response.Redirect("BookingForm.aspx");
}