Search code examples
asp.netfindcontrolcreateuserwizard

Can't clear credentials textboxes on ASP.NET CreateUserWizard Control


I have a CreateUserWizard control using forms authentication on my login/create user page. I customized the CreateUserWizardStep1 so that I could add some additional validators.

After successfully creating a user with the control and it displays "Complete Your account has been successfully created." I have added an additional button that will allow the person to create another user by setting the ActiveStepIndex = 0. The problem is, while it sets the ActiveStepIndex correctly, it retains the old user account credentials. I try to clear them manually using the following code, but they still stick...Anyone have any ideas?

   Protected Sub btnCreateAnotherUser_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    Me.cuwMain.ActiveStepIndex = 0
    CleanCreateNewUserInput()

End Sub

Private Sub CleanCreateNewUserInput()

    Dim txtUserName As TextBox
    txtUserName = FindControlIterative(Me.cuwMain, "UserName")
    txtUserName.Text = String.Empty

    Dim txtPassword As TextBox
    txtPassword = FindControlIterative(Me.cuwMain, "Password")
    txtPassword.Text = String.Empty

    Dim txtConfirmPassword As TextBox
    txtConfirmPassword = FindControlIterative(Me.cuwMain, "ConfirmPassword")
    txtConfirmPassword.Text = String.Empty

    Dim txtEmail As TextBox
    txtEmail = FindControlIterative(Me.cuwMain, "Email")
    txtEmail.Text = String.Empty

    Dim txtQuestion As TextBox
    txtQuestion = FindControlIterative(Me.cuwMain, "Question")
    txtQuestion.Text = String.Empty

    Dim txtAnswer As TextBox
    txtAnswer = FindControlIterative(Me.cuwMain, "Answer")
    txtAnswer.Text = String.Empty

End Sub

It finds the textboxes correctly, but it does not actually reset their values, even though in the debugger it says it did.

Thoughts ?


Solution

  • I feel silly posting this..., but I just turned viewstate off on the CreateUserWizard control and that did it.

    Thanks for the help Daniel, I now have a better understanding on how ASP.NET stores information.