Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Wizard Control

Reply
Thread Tools

Wizard Control

 
 
Morris Neuman
Guest
Posts: n/a
 
      04-21-2009
Hi,

I have a page with a wizard control. Note, this page does have a masterpage.

The wizard control has 5 steps; all steps have AllowReturn set to true.

Step 1 allows the user to browse, select and upload a spreadsheet. This
step also has a radiobuttonlist with values set to Fixed or Custom. In the
NextButtonClick script, if the value of the radiobuttonlist is fixed then the
wizard proceeds to step 2 otherwise to step 3 (Wizard1.ActiveStepIndex = 2)

Step2 has a formview with several textboxes . On the Formview, I have a
PreRender event set-up where I set-up default values to be displayed for
these textboxes. The user can update the values in these textboxes as
required then click next to go to Step 3.

Step 3 provides 2 buttons allowing the user additional capabilities. If
during this step the user selects the Previous button to go to step 2, I want
the textbox fields to display the values changed by the user not the default
values. How do I do this?

I tried the following but am having a problem.

I set-up 2 textbox fields on the page outside the wizard to contain the
value of the previous and next step index (textbox 3 is for the previous step
and textbox 4 is for the next step index as follows:
protected void OnActiveStepChanged_SaveCurrPrevIndex(object sender,
EventArgs e)
{
if (IsPostBack)
//NOT first time
{
TextBox3.Text = TextBox4.Text;
TextBox4.Text = Wizard1.ActiveStepIndex.ToString();

}
}

In the formview prerender script I try to check the value of these text
boxes. If the previous step is greater than the current step then I don't
want to display the default values.
protected void FV1_PreRender(object sender, EventArgs e)
{
TextBox tb3 = this.FindControl("TextBox3") as TextBox;
TextBox tb4 = this.FindControl("TextBox4") as TextBox;

int inttb3 = Convert.ToInt32(this.FindControl("TextBox3.Text")) ;
int inttb4 = Convert.ToInt32(this.FindControl("TextBox4.Text")) ;

if (inttb3 >= inttb4)
{
FormView FV1 = (FormView)sender;

TextBox tb1 = FV1.FindControl("TextBox1") as TextBox;
tb1.Text = "0";

TextBox tb2 = FV1.FindControl("TextBox2") as TextBox;
tb2.Text = "0123";
}
}

In the code above, I cannot get the values set-in textbox3 and textbox4.

I would like to know how to:
1) Show the default values only the first time the formview is displayed and
then show the values as they are if changed by the user;
2) How to access the textbox3 and textbox4 values in this prerender section.

Thanks as always for your help.
--
Morris
 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      04-22-2009
Hi Morris,

>Step 3 provides 2 buttons allowing the user additional capabilities. If
>during this step the user selects the Previous button to go to step 2, I

want
>the textbox fields to display the values changed by the user not the

default
>values. How do I do this?


If my understanding is correct, the following code can demonstrate your
scenario. For the simplicity I use TextBox to replace the FormView in your
case.

aspx:

<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step
1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step
2">
<asp:TextBox ID="TextBox1" runat="server"
OnPreRender="TextBox1_PreRender"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server"
Title="Step 3">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>

aspx.cs:

protected void TextBox1_PreRender(object sender, EventArgs e)
{

TextBox t = (TextBox)sender;
t.Text = "Default Value";


}

The problem is, if you go to step 2, change the value in the TextBox and
then go to step 3 and back to step 2. The value you changed is overwritten
because "Default Value" is reset in the PreRender event of TextBox.

The solution is, save a flag in ViewState, which can be preserved during
postbacks. We can use this flag to know if it's the first time to assign
value to TextBox.

The updated code:

protected void TextBox1_PreRender(object sender, EventArgs e)
{
if (ViewState["thefirsttime"] == null)
{
ViewState["thefirsttime"] = false;

TextBox t = (TextBox)sender;
t.Text = "Default Value";
}

}

Please test it and let me know if it works. If I misunderstood you please
send me a repro project. I'll test it on my side. My email is
. Please update here after sending the project in case
I missed that email.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



 
Reply With Quote
 
 
 
 
Morris Neuman
Guest
Posts: n/a
 
      04-22-2009
Thanks Allen. That worked.

A quick question, is "thefirsttime" a variable or a custom name to .net? I
tried to read-up on ViewState but info was hard to understand. Can you send
me a beginer's tutorial on viewstate?
--
Thanks
Morris


"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> >Step 3 provides 2 buttons allowing the user additional capabilities. If
> >during this step the user selects the Previous button to go to step 2, I

> want
> >the textbox fields to display the values changed by the user not the

> default
> >values. How do I do this?

>
> If my understanding is correct, the following code can demonstrate your
> scenario. For the simplicity I use TextBox to replace the FormView in your
> case.
>
> aspx:
>
> <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
> <WizardSteps>
> <asp:WizardStep ID="WizardStep1" runat="server" Title="Step
> 1">
> </asp:WizardStep>
> <asp:WizardStep ID="WizardStep2" runat="server" Title="Step
> 2">
> <asp:TextBox ID="TextBox1" runat="server"
> OnPreRender="TextBox1_PreRender"></asp:TextBox>
> </asp:WizardStep>
> <asp:WizardStep ID="WizardStep3" runat="server"
> Title="Step 3">
> </asp:WizardStep>
> </WizardSteps>
> </asp:Wizard>
>
> aspx.cs:
>
> protected void TextBox1_PreRender(object sender, EventArgs e)
> {
>
> TextBox t = (TextBox)sender;
> t.Text = "Default Value";
>
>
> }
>
> The problem is, if you go to step 2, change the value in the TextBox and
> then go to step 3 and back to step 2. The value you changed is overwritten
> because "Default Value" is reset in the PreRender event of TextBox.
>
> The solution is, save a flag in ViewState, which can be preserved during
> postbacks. We can use this flag to know if it's the first time to assign
> value to TextBox.
>
> The updated code:
>
> protected void TextBox1_PreRender(object sender, EventArgs e)
> {
> if (ViewState["thefirsttime"] == null)
> {
> ViewState["thefirsttime"] = false;
>
> TextBox t = (TextBox)sender;
> t.Text = "Default Value";
> }
>
> }
>
> Please test it and let me know if it works. If I misunderstood you please
> send me a repro project. I'll test it on my side. My email is
> . Please update here after sending the project in case
> I missed that email.
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> .
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#notifications.
>
> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 2 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions. Issues of this
> nature are best handled working with a dedicated Microsoft Support Engineer
> by contacting Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>

 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      04-23-2009
Hi Morris,

You can replace "thefirsttime" with anything you like. You can refer to the
following article to learn more details about ViewState.

http://msdn.microsoft.com/en-us/library/ms972976.aspx


Regards,
Allen Chen
Microsoft Online Support

 
Reply With Quote
 
Morris Neuman
Guest
Posts: n/a
 
      04-23-2009
Thanks.

I am wondering if you can check out my other issue in post Wizard Control -
Issue 2 and see if there is something you can recomend.

As always, I appreciate your feedback and help.
--
Thanks
Morris


"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> You can replace "thefirsttime" with anything you like. You can refer to the
> following article to learn more details about ViewState.
>
> http://msdn.microsoft.com/en-us/library/ms972976.aspx
>
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
>

 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      04-24-2009
Hi Morris,

>I am wondering if you can check out my other issue in post Wizard Control

-
>Issue 2 and see if there is something you can recomend.?


Thomas Sun is willing to assist on this issue. I've forwarded this thread
to him to let him know more about your scenario. You can follow up in the
original thread.

Thank you for using our Newsgroup Support Service.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

 
Reply With Quote
 
Morris Neuman
Guest
Posts: n/a
 
      04-24-2009
Thanks Allen. Got the answer from Thomas Sun.
--
Thanks
Morris


"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> >I am wondering if you can check out my other issue in post Wizard Control

> -
> >Issue 2 and see if there is something you can recomend.?

>
> Thomas Sun is willing to assist on this issue. I've forwarded this thread
> to him to let him know more about your scenario. You can follow up in the
> original thread.
>
> Thank you for using our Newsgroup Support Service.
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> .
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Choosing what wizard to display (or wizard steps) based on a dropDownList value Andy B ASP .Net 0 04-19-2008 11:36 AM
ASP.NET Wizard with Wizard Steps being User Controls bhakta.ram@gmail.com ASP .Net 0 09-21-2006 06:36 PM
How can I use Wizard Control Inside of FormView Control? John R. Lewis ASP .Net 0 01-04-2006 11:39 PM
Discreet 3ds Max v7.0, EDS.Unigraphics NX v3.0, bundled with Progressive.Die.Wizard, and Die.Design.Standard.Part.Library and Mold.Wizard, Cakewalk.SONAR 4 Producer Edition, Ableton.Live.v4.04, Arturia.CS80.V.v1.2, Pinnacle Studio Plus.v9.3 1, Systra astra35 NZ Computing 0 10-15-2004 11:41 AM
WinXP Microsoft Photo Printing Wizard, and Scanner and Camera Wizard Orak Listalavostok Digital Photography 5 07-10-2004 07:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57