Solved

How do I Assign role to new user with asp.net 2.0 CreateUserWizard

Posted on 2008-06-24
6
1,240 Views
Last Modified: 2013-12-16
I am trying to assign a role to my users when they signup. Im using the asp.net 2.0 CreateUserWizard.  It create the user, but does not assign the role.  Below is what i have for code.  Can some one show me what Im doing wrong?

Thanks for any help.

Code behind page:

protected void Page_Load(object sender, EventArgs e)
    {
 
    }
        protected void CreateUserWizard1_CreatedUser(
    object sender, EventArgs e)
    {  
         Roles.AddUserToRole(CreateUserWizard1.UserName, "Admin");
    }


html page:
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
            Height="195px" Width="367px">
            <WizardSteps>
                <asp:CreateUserWizardStep runat="server" />
                <asp:CompleteWizardStep runat="server" />
            </WizardSteps>
        </asp:CreateUserWizard>
0
Comment
Question by:bmanmike39
  • 3
  • 3
6 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21863147
replace:
Roles.AddUserToRole(CreateUserWizard1.UserName, "Admin");

with
Response.Write(CreateUserWizard1.UserName);

to make sure it is sending the name you thought it was sending. This will also make sure this event is firing.
0
 

Author Comment

by:bmanmike39
ID: 21863192
I replaced the line of code.  It created the user but did not fire response redirect.
0
 
LVL 21

Expert Comment

by:naspinski
ID: 21863246
ok, so that event is never actually firing.  In your aspx, it does not look like your CreateUserWizard has this event declared?  Otherwise, that event won't get fired.

oncreateduser="CreateUserWizard1_CreatedUser"
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:bmanmike39
ID: 21863255
where do i put this code?  in page load?
0
 
LVL 21

Accepted Solution

by:
naspinski earned 500 total points
ID: 21863298
no, inside your CreateUserWIzard Control
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"

            Height="195px" Width="367px"

            oncreateduser="CreateUserWizard1_CreatedUser">

            <WizardSteps>

                <asp:CreateUserWizardStep runat="server" />

                <asp:CompleteWizardStep runat="server" />

            </WizardSteps>

        </asp:CreateUserWizard>

Open in new window

0
 

Author Comment

by:bmanmike39
ID: 21863341
Thank it woked!!!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

746 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

9 Experts available now in Live!

Get 1:1 Help Now