If you are trying to add roles to users at the time of Creation here is a simple to do it. Simply drag the CreateUserWizard to your design view of the webform (or add it in source, whichever you are comfortable with).

When you first add it to the form and look at the source view it will look like this:

 
<asp:CreateUserWizard ID="wizCreateUser" runat="server">
  <WizardSteps>
    <asp:CreateUserWizardStep runat="server" />
    <asp:CompleteWizardStep runat="server" />
  </WizardSteps>
</asp:CreateUserWizard>
 

You will need click the "Customize User Step" in order to be able to add objects to this step. After the CreateUserWizard has been "Customized" you will be able to see a lot more of the wizard in the Html markup. This is where you want to add a CheckBoxList as shown below:

 
<tr>
<td align="right">
      Roles
   </td>
<td>
      <asp:CheckBoxList ID="chklistRoles" runat="server" />
   </td>
</tr>
 

This will allow you to display the roles and select them as needed.

Now, to actually do something with the roles.

In the code behind, you will find a method called wizCreateUser_CreatedUser. This is where you will add the following code:

 
protected void wizCreateUser_CreatedUser(object sender, EventArgs e)
{
  CheckBoxList chklistRoles = (CheckBoxList)
    wizCreateUser.CreateUserStep.ContentTemplateContainer.FindControl ("chklistRoles");
 
  foreach (ListItem li in chklistRoles.Items)
    {
      if (li.Selected)
        {
          Roles.AddUserToRole(wizCreateUser.UserName, li.ToString());
        }
     }
}
 

Good luck and I hope this helps.

 
<asp:TextBox Id="mytextbox" runat="server" Visible="false" />
 

If you are trying to read a value from a hidden textbox and you have the Visible attribute set to false, you will most certainly have problems.

To get around this, simply DO NOT set the Visible attribute to false.

Instead, set the style attribute to "Display: None;" like this.

 
<asp:TextBox Id="mytextbox" runat="server" Style="Display: None;" />
 
Tags: § § §