Acetamide
Acetamide

Reputation: 43

How to disabled button after user have clicked the button before in asp.net using C#

I am currently creating a seat reservation system. In my system, if user select Seat 1 and proceed till the end, when the system come back again (I have a button linked to first page from the last page), the Seat 1 should be disabled and cannot be chose already. But somehow my code still allows it to choose. Why is that?

I am using this code:

if (seat1 == "Reserved")
    {
        ImageButton1.ImageUrl = "seatreserved.png";
        ImageButton1.Enabled = false;
    }

The image does change so I know the value "Reserved" had successfully passed to this page. But somehow the ImageButton1.Enabled = false; did not work. Please help, thank you.

Upvotes: 1

Views: 149

Answers (2)

mybirthname
mybirthname

Reputation: 18137

You are not saving the state of your actions anywhere at least you don't explain it. When you reserve a seat in your app save the value of the seat in some source-> db xml or whatever you like. After that on the next opening of your app load the reserved seats from this source and make disable this buttons.

If you use DB and you have two tables Event and Reserving seats. When you click on the button you are inserting data in Reserving with EventID='The ID of Event' and SeatNumber the number of the seat.

After that when you go into this event again load the data from Reserving table for this Event and disable what is needed.

Upvotes: 1

PNP
PNP

Reputation: 371

try to clean project and rebuild again.. if problem still occurs then try to add new control and implement code again. Sometimes these kind of things happen in .Net Framework.

Upvotes: 0

Related Questions