<script runat="server">
Sub btnCreate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim userName As String = txtUserId.Text
'这个值式加密的或散列过,不会显示
Dim password As String = txtPassword.Text
Dim email As String = txtEmail.Text
Dim passwordQuestion As String = ddlPasswordQuestion.SelectedValue
'这个值式加密的或散列过,不会显示
Dim passwordAnswer As String = txtPasswordAnswer.Text
Dim result As MembershipCreateStatus
Membership.CreateUser(userName, password, email, passwordQuestion,
passwordAnswer, True, result)
lblResults.Visible = True
Select Case result
Case MembershipCreateStatus.Success
txtUserId.Text = Nothing
txtPassword.Text = Nothing
txtEmail.Text = Nothing
ddlPasswordQuestion.SelectedIndex = -1
txtPasswordAnswer.Text = Nothing
lblResults.Text = "User successfully created!"
Case MembershipCreateStatus.InvalidUserName
lblResults.Text = "The username format was invalid. Please enter a different username."
Case MembershipCreateStatus.InvalidPassword
lblResults.Text = "The password was invalid:
A password cannot be an empty string and must also meet the pasword
strength requirements of the configured provider. Please enter a new password."
Case MembershipCreateStatus.InvalidEmail
lblResults.Text = "The email format was invalid. Please enter a different username."
Case MembershipCreateStatus.InvalidQuestion
lblResults.Text = "The password question format was invalid.
Please enter a different question."
Case MembershipCreateStatus.InvalidAnswer
lblResults.Text = "The password answer format was invalid.
Please enter a different answer."
Case MembershipCreateStatus.DuplicateUsername
lblResults.Text = "The username is already in use. Please enter a new username."
Case MembershipCreateStatus.DuplicateEmail
lblResults.Text = "The email address is already in use.
Please enter a different email address."
Case Else
lblResults.Text = "An error occurred while creating the user."
End Select
End Sub
</script>