Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ulla Skaanning 67 posts 97 karma points
    Aug 28, 2010 @ 20:43
    Ulla Skaanning
    0

    assign roles to member upon signup

    Hi

    I'm trying to create a signup form where the user can select their langauge as one of the createuserwizard steps.

    The langauges correspond to the member group I've created in the members section of my Umbraco installation, and they are loaded into the createuserwizard from there, as elements in a checkboxlist.

    The problem is that the role is not assigned to the user when i  test it? 

    Can anyone spot the problem in my code below:

     

    <%@ Master Language="C#" MasterPageFile="/masterpages/RunwayTextpage.master" AutoEventWireup="true" %>

    <asp:content ContentPlaceHolderId="newsletterSignup" runat="server">

    <!-- NEWSLETTER SIGNUP -->

    <div id="newsletterSignup">

    <script runat="server">

    protected void Page_Load(object sender, EventArgs e) 

    if (!Page.IsPostBack) 

     // Reference the SpecifyRolesStep WizardStep 

     WizardStep SpecifyRolesStep = RegisterUserWithRoles.FindControl("SpecifyRolesStep") as WizardStep; 

     // Reference the RoleList CheckBoxList 

     CheckBoxList RoleList = SpecifyRolesStep.FindControl("RoleList") as CheckBoxList; 

     // Bind the set of roles to RoleList 

     RoleList.DataSource = Roles.GetAllRoles(); 

     RoleList.DataBind(); 

    }

    protected void RegisterUserWithRoles_ActiveStepChanged(object sender, EventArgs e) 

     { 

      // Have we JUST reached the Complete step? 

      if (RegisterUserWithRoles.ActiveStep.Title == "Complete") 

      { 

    // Reference the SpecifyRolesStep WizardStep 

    WizardStep SpecifyRolesStep = RegisterUserWithRoles.FindControl("SpecifyRolesStep") as WizardStep; 

     

    // Reference the RoleList CheckBoxList 

    CheckBoxList RoleList = SpecifyRolesStep.FindControl("RoleList") as CheckBoxList; 

     

    // Add the checked roles to the just-added user 

    foreach (ListItem li in RoleList.Items) 

     

    if (li.Selected) 

     Roles.AddUserToRole(RegisterUserWithRoles.UserName, li.Text); 

      } 

     }   

    </script>

    <asp:CreateUserWizard ID="RegisterUserWithRoles" runat="server" ContinueDestinationPageUrl="~/Default.aspx" LoginCreatedUser="False" CompleteSuccessText="<p>Thank you for registering.<p/>" CreateUserButtonText="Next"  UserNameLabelText="Username" ContinueButtonText="Next" InstructionText="Fill out the form with your name, password and the email address where you wish to receive the newsletter."> 

     

    <titleTextStyle CssClass="wizardTitle" />

         <labelStyle CssClass="wizardLabel" />

         <continueButtonStyle CssClass="wizardButton" />

         <createUserButtonStyle CssClass="wizardButton" />

    <CompleteSuccessTextStyle CssClass="wizardComplete" />

     

    <WizardSteps> 

              <asp:CreateUserWizardStep ID="CreateUserWizardStep1" Title="Newsletter Signup" runat="server"> 

              </asp:CreateUserWizardStep>  

    <asp:WizardStep ID="SpecifyRolesStep" runat="server" StepType="Step" Title="Specify Language(s)" AllowReturn="False"> 

    <asp:checkboxlist id="RoleList" runat="server"> </asp:checkboxlist>

    </asp:WizardStep> 

    <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"> 

    </asp:CompleteWizardStep> 

         </WizardSteps> 

    </asp:CreateUserWizard>

    </div> <!-- END NEWSLETTER SIGNUP -->

    </asp:content>

     

    Thank you :D

    / Ulla

     

Please Sign in or register to post replies

Write your reply to:

Draft