hi arun,
try a different approach. if the date is invalid, disable the next and
finish buttons and display the error message. presumably the user must not
be allowed to continue with an invalid date. they should probably cancel
the wizard if they can't enter a correct date. then if the user gets past
step 2, you don't need to go back and re-validate the date, there is no
logical reason to persist the boolean variable you refer to. if you have
proper validation in place, the user will never get to step 3 unless step 2
is successful.
however, if you really want to preserve the value of the boolean variable,
the explanation for why it is false is because you have taken no steps to
preserve its value across postbacks. remember that every postback is
essentially a single http request to the server. just because you put a
value into a variable of your page object, it does not mean that it will be
there for any future postbacks of the page, you must remember that as soon
as your code finishes executing on the server, that page object is
destroyed, along with all the values of its variables. asp.net makes sure
to preserve the state of the page between roundtrips via the viewstate.
with the technique i've outlined below, you can use the viewstate mechanism
to preserve your own values between postbacks.
you can put your boolean variable in viewstate at the end of step 2, and
then load it from viewstate in step 3 of your wizard.
e.g. pseudocode:
private void wizard1_NextButtonClick(etc...)
{
bool DateValid;
if(tabNumber == 2)
{
DateValid = whatever; // based on form contents...
ViewState["DateValid"] = DateValid; // save to viewstate
}
else if(tabNumber == 3)
{
// load from viewstate
DateValid =
Convert.ToBoolean(ViewState["DateValid"].ToString()); // you should check
for null value before doing this
if(DateValid)
blah blah blah
}
}
good luck
tim
"ar**@greettech.com" <ar**@visrez.comwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
Hi I am making a booking for a tour. The tours are allowed on some
days only( one on monday, other on tuesday like that).
For the booking object saving, I am using a wizrd control. In the
second step( next_button click of the wizard control ) I will decide
wether the date selected is valid or not and save it in a class level
boolean variable for use in the finish_button click of the wizard
control. if the boolean variable is true I will insert the booking
else leave it by displaying the error. If inserted I will goto a
gridview showing all bookings from where I can do individual editing of
bookings( for this i am passing the booking id as querystring and will
go to the booking creation page itself).
The problem is even if i get true, in next button click event of
wizard, in finish _button click of wizard it is showing false. So
the allowed bookings are also not getting inserted . Any idea how to
handle this situation?