473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

problem with c# code

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?

Jan 22 '07 #1
7 1562
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?
Jan 22 '07 #2
Hi Tim
Thanks for Your timely Reply...
Get back to you soon
Arun

Jan 23 '07 #3
Hi Tim

Please suggest me how I can disable the (first and) next button of the
wizard. This when combined with displaysidebar=false will help me...so
that user cant forward further

Thank you very much for the information

Arun

Jan 23 '07 #4
hi arun,
i looked into further and apparently you can't disable the button as i
suggested.
what you can do is cancel the NextButtonClick if the input does not pass
your validation test.

protected void Wizard1_NextButtonClick(object sender,
WizardNavigationEventArgs e)
{
if(String.IsNullOrEmpty(this.TextBox1.Text))
{
e.Cancel = true; // do not permit the user to proceed
this.lblError.Text = "Please enter some text and try again";
}
}

i hope this does it for you
thanks
tim

"ar**@greettech.com" <ar**@visrez.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
Hi Tim

Please suggest me how I can disable the (first and) next button of the
wizard. This when combined with displaysidebar=false will help me...so
that user cant forward further

Thank you very much for the information

Arun
Jan 23 '07 #5
Hi Tim,

Thanks for the help....
>From one of the web sites I got the following code
protected void Wizard1_NextButtonClick(object sender,
WizardNavigationEventArgs e)
{ WizardStepType t =
Wizard1.WizardSteps[e.CurrentStepIndex].StepType;
Response.Write(t.ToString());
}

And from the object brwser I got the possible values for WizardStepType
are

Auto,
Start,
Step,
Finish,
Complete

But when I run the above code always I am getting 'Auto '. Why is it so?

Jan 24 '07 #6
Hi Tim,

Thanks for the help....

We can disable the next and previous buttons by the folowing code(you
have to convert the wizard step to stepnavigation or other templates )

if (Wizard1.ActiveStepIndex == 1)
{

Button NextButton =
(Button)(Wizard1.FindControl("StepNavigationTempla teContainerID$StepNextButton"));
NextButton.Enabled = false;
}
>From one of the web sites I got the following code

protected void Wizard1_NextButtonClick(object sender,
WizardNavigationEventArgs e)
{ WizardStepType t =
Wizard1.WizardSteps[e.CurrentStepIndex].StepType;
Response.Write(t.ToString());
}

And from the object brwser I got the possible values for WizardStepType

are
Auto,
Start,
Step,
Finish,
Complete
But when I run the above code always I am getting 'Auto '. Why is it
so?

Jan 24 '07 #7
hi arun,
i presume that it says 'Auto' because you haven't explicitly set the type of
any of the steps.
i also presume that auto means the first step has no back button, and that
the last step says 'finish' instead of next etc., without you having to
configure the step behaviour individually.

personally i would prefer to just cancel the NextButtonClick event, rather
than dig into the controls to find the ''next' button and then disable it
etc. but you may think it's worth the extra work.

tim
"ar**@greettech.com" <ar**@visrez.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
Hi Tim,

Thanks for the help....

We can disable the next and previous buttons by the folowing code(you
have to convert the wizard step to stepnavigation or other templates )

if (Wizard1.ActiveStepIndex == 1)
{

Button NextButton =
(Button)(Wizard1.FindControl("StepNavigationTempla teContainerID$StepNextButton"));
NextButton.Enabled = false;
}
>>From one of the web sites I got the following code


protected void Wizard1_NextButtonClick(object sender,
WizardNavigationEventArgs e)
{ WizardStepType t =
Wizard1.WizardSteps[e.CurrentStepIndex].StepType;
Response.Write(t.ToString());
}

And from the object brwser I got the possible values for WizardStepType

are
Auto,
Start,
Step,
Finish,
Complete
But when I run the above code always I am getting 'Auto '. Why is it
so?
Jan 24 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
7
by: Keith Dewell | last post by:
Greetings! My current job has brought me back to working in C++ which I haven't used since school days. The solution to my problem may be trivial but I have struggled with it for the last two...
6
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
2
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.