2011-01-22 2 views
1

CreateUserWizard.CreatedUser 동안 역할에 사용자를 추가하는 방법은 무엇입니까?CreateUserWizard.CreatedUser 단계에서 역할에 사용자를 추가하는 방법

이 코드에 잘못의 새로운 기능 :

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles CreateUserWizard1.CreatedUser 
    Dim username As TextBox = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName") 
    Dim literal1 As Literal = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Literal1") 
    Dim sql As SqlDataSource = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SqlDataSource1") 
    Dim user As MembershipUser = Membership.GetUser(username.Text) 
    Dim pwd As TextBox = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password") 
    Dim obj As Object 
    obj = user.ProviderUserKey 
    sql.InsertParameters.Add("UserId", obj.ToString) 
    Roles.AddUserToRole(CreateUserWizard1.UserName, literal1.Text.ToString) 
    sql.Insert() 
End Sub 

오류 : 난 당신이 사용하는 마법사, 당신은 줄 당신 희미한 사용자에 오류가 있습니다 익숙하지 오전

The parameter 'username' must not be empty. Parameter name: username.

+0

/default 회원 공급자가 설치되어 있습니까? 기본 제공 멤버십/역할 인프라/데이터베이스를 사용하고 있습니까? – abatishchev

답변

0

? 또는 나중에 roles.addUserToRole?

role.addUserToRole에서만 가져 오는 경우 사용자를 흐리게했을 때 사용한대로 CreateWizard1.UserName을 username.text로 변경하지 않으시겠습니까?