Adding roles to the 'CreateUserWizard'

前端 未结 3 550
星月不相逢
星月不相逢 2021-01-12 19:35

Hi (I\'m pretty new to this),

Is it possible to add roles to the \'CreateUserWizard\' tool so that you tick boxes (or view roles in a drop down menu) and once one or

3条回答
  •  星月不相逢
    2021-01-12 20:06

    Briefly, what you need to do is to add the roles dropdown/checklist control somewhere in the section.

    Since the control is in a Template, you need to use the following code to find the control in the code behind:

    roleDropDownList = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl( "RoleDropDownList" );
    

    You'd bind it like you normally would bind a control in the Page_Init.

    To add the user to the role, use the CreatedUser event of the CreateUserWizard control.

    protected void CreateUserWizard1_CreatedUser( object sender, EventArgs e )
    {
      Roles.AddUserToRole( CreateUserWizard1.UserName, roleDropDownList.SelectedValue );
    }
    

提交回复
热议问题