Solved

CreateUser not forwarding to next step

Posted on 2010-09-16
3
411 Views
Last Modified: 2013-11-07
I created a registration process that includes capturing user fullname and assigning a role.  When user presses the 'Create User' button, Two events are called 1) the CreatingUser - validates the baisc user information, the other information had been validated on previous steps (1 & 2).  2) Event is the CreatedUser - this event adds additional information to the a unique table, followed by sending captured values to a summary page.

My Problem, Steps 1 & 2 are completed successfully, The new user is even logged in, and activeindexstep is set to (Me.CompleteWizardStep3) however I am not going to summary step it returns to the CreateUserWizard Step.

Some of my troubleshooting:
1)  I've taken out all data capturing or sending to summary page - NoGo
2)  In stead of setting active index with Me.CompleteWizardStep3, I substituted that with the number 3 and even 4 to see if I could produce an error - NoGo
3)  Placed error trapping throughout this part of the code - NoGo

Are there any other suggestion, any thoughts are appreciated.
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs)

        'Insert Data into table and Add other pertinent data

        Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")

        Dim createDate As Date = DateTime.Now.ToString("MM/dd/yy")



        'Dim rowsAffected As Integer

        Dim rIdentity As Integer = -1

        Try

            Dim myConnectionString As String

            Dim myQuery As String

            Dim myConnection As SqlConnection

            Dim cmd As SqlCommand



            myConnectionString = "Data Source=SERVERIP;Initial Catalog=aspnetdb; User Id=USERID; Password=PASSWORD;"

            myQuery = "INSERT INTO aspnet_UserName (UserName, Firstname, Lastname, Prefixname, Suffixname, Nickname, " _

                & "CreateDate, AccountStatus, OrgNameID) VALUES ('" _

                & UserNameTextBox.Text & "', '" & Firstname.Text & "', '" & Lastname.Text & "', '" & PrefixnameDDL.Text & "', '" _

                & Suffix.Text & "', '" & Nickname.Text & "', '" & createDate & "', 'Enabled', '" _

                & getOrgNameID(OrganizationDDL.Text) & "') SELECT SCOPE_IDENTITY();"

            myConnection = New SqlConnection(myConnectionString)

            myConnection.Open()

            cmd = New SqlCommand(myQuery, myConnection)

            'rowsAffected = cmd.ExecuteNonQuery()

            rIdentity = Integer.Parse(cmd.ExecuteScalar().ToString()) 'Get the @Identity Column

            myConnection.Close()



        Catch ex As Exception

            ClientScript.RegisterStartupScript(Me.GetType(), "alert", "<script language='javascript'>alert('CreateUserWizard1_CreatedUser produce the following error: " + ex.Message + "');</script>")

            Response.Write(ex.Message)

        End Try



        'Call the Summary Sub-Routine

        setSummaryPage()



        Dim UserNameTB As TextBox = CType(CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName"), TextBox)

        'Place user name in as a session variable so the name can be access on the Entity Home page

        Session.RemoveAll()

        Session("authUserName") = UserNameTB.Text



        'Set Next Step

        Try

            If CreateUserWizard1.WizardSteps.IndexOf(Me.CompleteWizardStep3) > 3 Then

                Throw New ArgumentOutOfRangeException("Index", "Index is out of range")

            End If

            CreateUserWizard1.ActiveStepIndex = CreateUserWizard1.WizardSteps.IndexOf(Me.CompleteWizardStep3)



            'ClientScript.RegisterStartupScript(Me.GetType(), "alert", "<script language='javascript'>alert('" + CreateUserWizard1.ActiveStepIndex.ToString + "');</script>")

        Catch aEx As ArgumentOutOfRangeException

            Response.Write(aEx.Message)

        End Try



    End Sub





SUMMARY SUBROUTINE:



 Protected Sub setSummaryPage()

        'Populate Basic user information before displaying Summary page

        Try

            If CreateUserWizard1.ActiveStepIndex = 2 Then

                Dim UserNameTB As TextBox = CType(CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName"), TextBox)

                Dim PasswordTB As TextBox = CType(CreateUserWizardStep2.ContentTemplateContainer.FindControl("Password"), TextBox)

                Dim SecurityQuestionTB As DropDownList = CType(CreateUserWizardStep2.ContentTemplateContainer.FindControl("QuestionDDL"), DropDownList)

                Dim SecurityAnswerTB As TextBox = CType(CreateUserWizardStep2.ContentTemplateContainer.FindControl("Answer"), TextBox)

                Dim SecurityEmailTB As TextBox = CType(CreateUserWizardStep2.ContentTemplateContainer.FindControl("Email"), TextBox)

                'Set fields

                Dim UserNameLb As Label = CType(CompleteWizardStep3.FindControl("UserNameEntry"), Label)

                Dim PasswordLb As Label = CType(CompleteWizardStep3.FindControl("PasswordEntry"), Label)

                Dim SecurityQuestionLb As Label = CType(CompleteWizardStep3.FindControl("SecurityQuestionEntry"), Label)

                Dim SecurityAnswerLb As Label = CType(CompleteWizardStep3.FindControl("SecurityAnswerEntry"), Label)

                Dim SecurityEmailLb As Label = CType(CompleteWizardStep3.FindControl("SecurityEmailEntry"), Label)



                UserNameLb.Text = UserNameTB.Text

                PasswordLb.Text = PasswordTB.Text

                SecurityQuestionLb.Text = SecurityQuestionTB.Text

                SecurityAnswerLb.Text = SecurityAnswerTB.Text

                SecurityEmailLb.Text = SecurityEmailTB.Text



                'Assing user to Role

                AssignUserToRoles_Deactivate()

            End If

        Catch ex As Exception



            ClientScript.RegisterStartupScript(Me.GetType(), "alert", "<script language='javascript'>alert('Populating User Summary Information produce the following error: " + ex.Message + "');</script>")

            Response.Write(ex.Message)

        End Try



    End Sub

Open in new window

0
Comment
Question by:Robert Treadwell
  • 2
3 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 33692994
So what is the order of Steps?
If your summary is a wizard step after CreateUserStep, it should be activated by itself.
Check if this video helps:
http://www.asp.net/general/videos/how-do-i-secure-my-site-using-membership-and-roles
You are interested in starting at 10th minute.

or this article: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
0
 

Author Comment

by:Robert Treadwell
ID: 33693447
Thank you for the linked resources I used those or ones like them.  The number of steps are 4:
Step 0 - Capture Fullname ,
Step 1 - Capture Role,
Step 2 - Capture username, password and security Q&A,
Step 3 - Summarry Page

The reason I placed the ActiveStepIndex line 45 in my code because Step 2 was not forwarding to Step 3.
And
Even with line 45 it is still not forwarding.
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 33693844
You don't need to set the index manually. Below is a simple sample I tested and it works.
Step1: Get Name
Step2: Get login info
Sted3: Display summary
Step4: Success

        <asp:CreateUserWizard ID="CreateUserWizard1"
            runat="server">
            <WizardSteps>
                <asp:WizardStep runat="server" Title="Personal Info">
                    <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </asp:WizardStep>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep1"
                    runat="server">
                </asp:CreateUserWizardStep>
                <asp:WizardStep runat="server" Title="Summary" OnActivate="Summary_Activate">
                    <asp:Label ID="lblSummary" runat="server" Text="Label"></asp:Label>
                </asp:WizardStep>
                <asp:CompleteWizardStep ID="CompleteWizardStep1"
                    runat="server">
                </asp:CompleteWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>

Code-behind ..Summary_Activate handler:

public void Summary_Activate(object sender, EventArgs e)
    {
        String summary = "Name: - " + TextBox1.Text + "<br />";
        summary += "Username: - " + CreateUserWizard1.UserName + "<br />";
        lblSummary.Text = summary;
    }

Note: If you want to display summary in CompletWizardStep you can use same logic.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 33
Remove greater than sign 3 42
C# Single Form 8 27
Gridview alignment 1 8
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now