Membership - CreateUser - enforce Role selection

Posted on 2008-11-19
Last Modified: 2012-05-05
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.
Question by:vu3lmg
    1 Comment
    LVL 13

    Accepted Solution

    You can create user something like that
                MembershipCreateStatus Status;
                "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();

    finaly you can add user to Role

    Roles.AddUserToRole(User.Identity.Name, "Power User");

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 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

    19 Experts available now in Live!

    Get 1:1 Help Now