Membership - CreateUser - enforce Role selection

I am developing application in ASP.NET 2.0.
I am using the "membership" profile for user maintenance.
On the Create user screen I am using the "CreateUserWizard".
How can I enforce (add Role selection dropdown) while creating a new user.
LVL 1
vu3lmgAsked:
Who is Participating?
 
sm394Connect With a Mentor Commented:
You can create user something like that
try
        {
               
            MembershipCreateStatus Status;
            Membership.CreateUser("UserName1",
            "1234567890-",
            "UserEmail1@yahoo.com",
            "hello",
            "hello", true,
            out Status);
            StatusLabel.Text = "User created successfully!";
        }
        catch (Exception ex)
        {
            Debug.WriteLine("Exception: " + ex.Message);
            StatusLabel.Text = "Unable to create user!";
        }

then you can get existing roles
        lbxAvailableRoles.DataSource = Roles.GetAllRoles();
        lbxAvailableRoles.DataBind();

finaly you can add user to Role

Roles.AddUserToRole(User.Identity.Name, "Power User");
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.