Passing user entered data between createuserwizard steps

Last post 08-02-2007 2:14 AM by Peronn. 5 replies.

Sort Posts:

  • Passing user entered data between createuserwizard steps

    08-01-2007, 3:07 PM
    • Member
      11 point Member
    • JWalker67
    • Member since 07-27-2007, 2:02 AM
    • Posts 50

    I have a multi-step create user setup.  On the first page I ask for the users first name and last name.  On the next step I want to display the users first and last name, but I have been unable to figure out how to pass those values to the next step.

    I have found numerous examples but each one has failed.  I think there are things (steps) left out assuming the reader knows those steps.  that is not always the case.

    I am programing in C# and would appreciate any complete code example(s).

    Thank you in advance

  • Re: Passing user entered data between createuserwizard steps

    08-01-2007, 3:41 PM
    • Member
      161 point Member
    • Peronn
    • Member since 02-24-2006, 4:39 AM
    • Sweden
    • Posts 47
    Hi JWalker67 A few questions. What are the steps? Are they different aspx-pages or are they for example an asp.net wizard control? If you could use the wizard control it would solve the problems for you since it stores tha values in the controls so you can get them in later steps if you want. If the steps are different aspx pages then that is a bit unessecary if it doesn't fill a specific function but it can be done. You can either add the values to the querystring and read them from the query string on the next step or try to store them in the session/cache. Tell me more about what ype of solution our after and iäll be able to help you more. Best regards, Per
    If my answer was useful then please mark as answer. Thank you.
  • Re: Passing user entered data between createuserwizard steps

    08-01-2007, 4:01 PM
    • Member
      11 point Member
    • JWalker67
    • Member since 07-27-2007, 2:02 AM
    • Posts 50

    Here is a snippet of what I currently have in place:
    asp:CreateUserWizard ID="CreateUserWizard1" ...
    WizardSteps
    asp:WizardStep ID="wizStep1"

    ...within a table...
    asp:label ID="FirstNameLabel" Text="First Name:"
    asp:textbox ID="FirstName"

    /asp:WizardStep
    asp:CreateUserWizardStep ID="CreateUserWizardStep1
    ContentTemplate

    ...within a table...
    Hello, WANT FIRST NAME & LAST NAME HERE
    /ContentTemplate
    /asp:CreateUserWizardStep
    asp:CompleteWizardStep
    ...
    /ContentTemplate
    /asp:CompleteWizardStep
    /asp:CreateUserWizard

    All of this is within one .aspx page.  I have edited out the brackets and such so I hope it makes sense.  If not I can post the actual code

  • Re: Passing user entered data between createuserwizard steps

    08-01-2007, 4:32 PM

    just try in your codebehind (.cs),  FirstName.Text...It should get you the object no matter which step you are in... let us know if you still have trouble.

    Thanks,

    http://dotnet-tips.blogspot.com/
  • Re: Passing user entered data between createuserwizard steps

    08-01-2007, 5:04 PM
    • Member
      124 point Member
    • jmccarthy
    • Member since 07-31-2007, 2:49 PM
    • Fort Lauderdale, FL
    • Posts 30

    Since you are using one WebApp with different user controls. You could pass the data back and forth by using Session variables.

     

    [VB] 

    Session("FirstName") = "John"
    Session("LastName") = "Walker"

     Label1.Text = Session("FirstName") + " " + Session("LastName")

     

    [C#]

    Session["FirstName"] = "John"
    Session["LastName"] = "Walker"

     Label1.Text = Session["FirstName"].ToString() + " " + Session["LastName"].ToString()

    -- Signed --
    J. McCarthy
  • Re: Passing user entered data between createuserwizard steps

    08-02-2007, 2:14 AM
    Answer
    • Member
      161 point Member
    • Peronn
    • Member since 02-24-2006, 4:39 AM
    • Sweden
    • Posts 47

    As the two persons above have said you can either use the sessionvariables or getting the data directly from the control. The second approach is in my oppinion the best one for you here is a code example for the code in the aspx page:

    1    <asp:Wizard ID="Wizard1" runat="server" onactivestepchanged="Wizard1_ActiveStepChanged">
    2            <WizardSteps>
    3                <asp:WizardStep ID="WizardStep1" Title="Step 1" runat="server">
    4                    <asp:TextBox ID="FirstNameTextBox" runat="server"></asp:TextBox>
    5                    <asp:TextBox ID="LastNameTextBox" runat="server"></asp:TextBox>
    6                </asp:WizardStep>
    7                <asp:WizardStep ID="WizardStep2" Title="Step 2" runat="server">
    8                    <asp:Label ID="CompleteNameLabel" runat="server" Text="Label"></asp:Label>
    9                </asp:WizardStep>
    10           </WizardSteps>
    11   </asp:Wizard>
    

     

    Then in your code behind (the C# code) you will need the following code:

    1    /// <summary>
    2    /// This method is called everytime the user changes the active steps.
    3    /// Moves forwards or backwards in the wizard.
    4    /// </summary>
    5    protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
    6    {
    7         //You have to check what step the user is going to
    8         //Step 0 is where you have the textboxes for entering names and
    9         //step 1 is where you want the greeting. The first step is always 0
    10        //not 1 hence the second step is 1
    11        if (Wizard1.ActiveStepIndex == 1)
    12            CompleteNameLabel.Text = "Hello " + FirstNameTextBox.Text + " " + LastNameTextBox.Text;
    13   }
    

    Note that the wizard uses the event onactivestepchanged. To generate this in the codebehind (the easiest way) then in design mode click your wizard and in the propertys click the yellow flash to display the elements then double click in the empty field next to the text ActiveStepChanged.

    I hope this helps!

    Best regards
    Per

    If my answer was useful then please mark as answer. Thank you.
Page 1 of 1 (6 items)