Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 27, 2012 11:38 AM by Frank Jiang - MSFT
Member
4 Points
19 Posts
Apr 25, 2012 03:27 AM|LINK
Hi i have a project where everytime a new booking is confirmed the RoomBookingMain.aspx is updated to show the number of bookings.
I have 2 webpages. GenerateBooking.aspx and RoomBookingMain.aspx
code in GenerateBooking.aspx for the confirm button is:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Response.Redirect("RoomBookingMain.aspx"); Session["confirmBooking"] = "confirm"; Session["totalBooking"] = totRateTextBox.Text;
and code in RoomBookingMain.aspx is
public partial class RoomBookingMain : System.Web.UI.Page { static int nbBookingInt = 0; static int totalRevenueInt = 0; protected void Page_Load(object sender, EventArgs e) {
bookingNLabel.Text = nbBookingInt.ToString(); totRevenueLabel.Text = totalRevenueInt.ToString();
if (Session["confirmBooking"] == "confirm") { nbBookingInt = nbBookingInt + 1; Session["confirmBooking"] = "no current booking"; }
Just would like to know why the bookingLabel is not being updated.
Any Help on this would be appreciated.
Thanks Sahil
All-Star
18774 Points
3637 Posts
Apr 25, 2012 03:33 AM|LINK
You are updating nbBookingInt after you set the bookingLabel. You need to set the bookingLabel.Text property after your if-block.
if (Session["confirmBooking"] == "confirm") { nbBookingInt = nbBookingInt + 1; Session["confirmBooking"] = "no current booking"; } bookingLabel.Text = nbBookingInt.ToString(); totRevenueLabel.Text = totalRevenueInt.ToString();
Apr 25, 2012 03:43 AM|LINK
I just did that but the label still showing 0?
Apr 25, 2012 03:56 AM|LINK
Try debugging the code and see if you actually go into the if-block.
Apr 25, 2012 04:00 AM|LINK
Yeah its the first thing it does. goes straight to the if block
Apr 25, 2012 04:43 AM|LINK
And then what happened after the if-block when you are setting your BookingLabel.Text property?
16006 Points
1728 Posts
Microsoft
Apr 27, 2012 11:38 AM|LINK
I fixed your code. now it is working
GenerateBooking.aspx
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Session["confirmBooking"] = "confirm"; Session["totalBooking"] = totRateTextBox.Text; Response.Redirect("RoomBookingMain.aspx"); }
RoomBookingMain.aspx
static int nbBookingInt = 0; static int totalRevenueInt = 0; protected void Page_Load(object sender, EventArgs e) { if (Session["confirmBooking"] == "confirm") { nbBookingInt = nbBookingInt + 1; Session["confirmBooking"] = "no current booking"; } bookingNLabel.Text = nbBookingInt.ToString(); totRevenueLabel.Text = totalRevenueInt.ToString(); }
S-Yandel
Member
4 Points
19 Posts
Updating Static Int.
Apr 25, 2012 03:27 AM|LINK
Hi i have a project where everytime a new booking is confirmed the RoomBookingMain.aspx is updated to show the number of bookings.
I have 2 webpages. GenerateBooking.aspx and RoomBookingMain.aspx
code in GenerateBooking.aspx for the confirm button is:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("RoomBookingMain.aspx");
Session["confirmBooking"] = "confirm";
Session["totalBooking"] = totRateTextBox.Text;
and code in RoomBookingMain.aspx is
public partial class RoomBookingMain : System.Web.UI.Page
{
static int nbBookingInt = 0;
static int totalRevenueInt = 0;
protected void Page_Load(object sender, EventArgs e)
{
bookingNLabel.Text = nbBookingInt.ToString();
totRevenueLabel.Text = totalRevenueInt.ToString();
if (Session["confirmBooking"] == "confirm")
{
nbBookingInt = nbBookingInt + 1;
Session["confirmBooking"] = "no current booking";
}
Just would like to know why the bookingLabel is not being updated.
Any Help on this would be appreciated.
Thanks Sahil
Careed
All-Star
18774 Points
3637 Posts
Re: Updating Static Int.
Apr 25, 2012 03:33 AM|LINK
You are updating nbBookingInt after you set the bookingLabel. You need to set the bookingLabel.Text property after your if-block.
if (Session["confirmBooking"] == "confirm") { nbBookingInt = nbBookingInt + 1; Session["confirmBooking"] = "no current booking"; } bookingLabel.Text = nbBookingInt.ToString(); totRevenueLabel.Text = totalRevenueInt.ToString();"The oxen are slow, but the earth is patient."
S-Yandel
Member
4 Points
19 Posts
Re: Updating Static Int.
Apr 25, 2012 03:43 AM|LINK
I just did that but the label still showing 0?
Careed
All-Star
18774 Points
3637 Posts
Re: Updating Static Int.
Apr 25, 2012 03:56 AM|LINK
Try debugging the code and see if you actually go into the if-block.
"The oxen are slow, but the earth is patient."
S-Yandel
Member
4 Points
19 Posts
Re: Updating Static Int.
Apr 25, 2012 04:00 AM|LINK
Yeah its the first thing it does. goes straight to the if block
Careed
All-Star
18774 Points
3637 Posts
Re: Updating Static Int.
Apr 25, 2012 04:43 AM|LINK
And then what happened after the if-block when you are setting your BookingLabel.Text property?
"The oxen are slow, but the earth is patient."
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Updating Static Int.
Apr 27, 2012 11:38 AM|LINK
I fixed your code. now it is working
GenerateBooking.aspx
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Session["confirmBooking"] = "confirm"; Session["totalBooking"] = totRateTextBox.Text; Response.Redirect("RoomBookingMain.aspx"); }RoomBookingMain.aspx
static int nbBookingInt = 0; static int totalRevenueInt = 0; protected void Page_Load(object sender, EventArgs e) { if (Session["confirmBooking"] == "confirm") { nbBookingInt = nbBookingInt + 1; Session["confirmBooking"] = "no current booking"; } bookingNLabel.Text = nbBookingInt.ToString(); totRevenueLabel.Text = totalRevenueInt.ToString(); }Feedback to us
Develop and promote your apps in Windows Store