Compartilhar via


Como: Personalizar o controle CreateUserWizard ASP.NET

Você pode personalizar o conteúdo do controle CreateUserWizard usando os modelos CreateUserWizardStepCompleteWizardStep.Especificando o conteúdo dos modelos, você pode especificar sua própria interface de usuário (UI) personalizada que inclui os controles que o controle CreateUserWizard usa para coletar informações sobre o novo usuário, assim como os controles adicionais que você especificar (para obter uma lista dos controles que o controle CreateUserWizard usa, consulte Personalizando a Aparência dos Controles de Login do ASP.NET.)

Além disso, devido ao controle CreateUserWizard herdar da classe Wizard, você pode adicionar seus próprios passos personalizados para o controle CreateUserWizard.Para mais informações, consulte Wizard control, see Visão Geral Sobre Controle de Servidor Web do Wizard.

Observação:

Você também pode personalizar a aparência das CreateUserWizard usando temas e propriedades de estilo de controle. Para detalhes, consulte Visão Geral de Temas e Aparências ASP.NET e as propriedades do controle CreateUserWizard.

Para personalizar as etapas CreateUserWizard

  1. Coloque um controle CreateUserWizard na sua página usando a seguinte sintaxe:

    <asp:CreateUserWizard ID="CreateUserWizard1" Runat="server">
      <WizardSteps>
        <asp:CreateUserWizardStep >
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep >
        </asp:CompleteWizardStep>
      </WizardSteps>
    </asp:CreateUserWizard>
    
  2. Para personalizar a etapa de criação da conta de usuário, crie um elemento <ContentTemplate> dentro do elemento <asp:CreateUserWizardStep>.Dentro do modelo, adicione marcação e controles para definir o layout e o conteúdo de interface para a coleta de informações do usuário que você precisa.

    Observação:

    Se seu provedor de associação estende o MembershipProvider classe com membros personalizados, você deve adicionar quaisquer controles para reunir informações exigidas pelo seu associação provedor para criar um novo usuário personalizado. Para obter detalhes, consulte:CreateUserWizardStep.

    O exemplo de código a seguir mostra uma propriedade CreateUserStep que inclui controles CheckBox que permitem aos usuários especificar opções adicionais.

    <asp:CreateUserWizardStep ID="CreateUserWizardStep1" >
        <ContentTemplate>
            <table border="0" style="font-size: 100%; font-family: Verdana">
                <tr>
                    <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                        Sign Up for Your New Account</td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="UserNameLabel"  AssociatedControlID="UserName">
                            User Name:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="UserName" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired"  ControlToValidate="UserName"
                            ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="PasswordLabel"  AssociatedControlID="Password">
                            Password:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Password"  TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired"  ControlToValidate="Password"
                            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="ConfirmPasswordLabel"  AssociatedControlID="ConfirmPassword">
                            Confirm Password:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="ConfirmPassword"  TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="ConfirmPasswordRequired"  ControlToValidate="ConfirmPassword"
                            ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="EmailLabel"  AssociatedControlID="Email">
                            E-mail:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Email" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="EmailRequired"  ControlToValidate="Email"
                            ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="QuestionLabel"  AssociatedControlID="Question">
                            Security Question:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Question" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="QuestionRequired"  ControlToValidate="Question"
                            ErrorMessage="Security question is required." ToolTip="Security question is required."
                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="AnswerLabel"  AssociatedControlID="Answer">
                            Security Answer:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Answer" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="AnswerRequired"  ControlToValidate="Answer"
                            ErrorMessage="Security answer is required." ToolTip="Security answer is required."
                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <asp:CompareValidator ID="PasswordCompare"  ControlToCompare="Password"
                            ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                            ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2" style="color: red">
                        <asp:Literal ID="ErrorMessage"  EnableViewState="False"></asp:Literal>
                    </td>
                </tr>
            </table>
            <asp:CheckBox ID="SubscribeCheckBox"  Checked="True" Text="Send me a monthly newsletter." />
            <br />
            <asp:CheckBox ID="ShareInfoCheckBox"  Checked="True" Text="Share my information with partner sites." />
        </ContentTemplate>
    </asp:CreateUserWizardStep>
    
    <asp:CreateUserWizardStep ID="CreateUserWizardStep1" >
        <ContentTemplate>
            <table border="0" style="font-size: 100%; font-family: Verdana">
                <tr>
                    <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                        Sign Up for Your New Account</td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="UserNameLabel"  AssociatedControlID="UserName">
                            User Name:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="UserName" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired"  ControlToValidate="UserName"
                            ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="PasswordLabel"  AssociatedControlID="Password">
                            Password:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Password"  TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired"  ControlToValidate="Password"
                            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="ConfirmPasswordLabel"  AssociatedControlID="ConfirmPassword">
                            Confirm Password:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="ConfirmPassword"  TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="ConfirmPasswordRequired"  ControlToValidate="ConfirmPassword"
                            ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="EmailLabel"  AssociatedControlID="Email">
                            E-mail:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Email" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="EmailRequired"  ControlToValidate="Email"
                            ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="QuestionLabel"  AssociatedControlID="Question">
                            Security Question:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Question" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="QuestionRequired"  ControlToValidate="Question"
                            ErrorMessage="Security question is required." ToolTip="Security question is required."
                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="AnswerLabel"  AssociatedControlID="Answer">
                            Security Answer:</asp:Label></td>
                    <td>
                        <asp:TextBox ID="Answer" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="AnswerRequired"  ControlToValidate="Answer"
                            ErrorMessage="Security answer is required." ToolTip="Security answer is required."
                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <asp:CompareValidator ID="PasswordCompare"  ControlToCompare="Password"
                            ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                            ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2" style="color: red">
                        <asp:Literal ID="ErrorMessage"  EnableViewState="False"></asp:Literal>
                    </td>
                </tr>
            </table>
            <asp:CheckBox ID="SubscribeCheckBox"  Checked="True" Text="Send me a monthly newsletter." />
            <br />
            <asp:CheckBox ID="ShareInfoCheckBox"  Checked="True" Text="Share my information with partner sites." />
        </ContentTemplate>
    </asp:CreateUserWizardStep>
    
  3. Para personalizar a etapa de conclusão, crie um elemento <ContentTemplate> dentro do elemento <asp:CompleteWizardStep>.Dentro do modelo, adicione a marcação e controles para definir o layout e o conteúdo de interface do usuário para exibir uma mensagem de confirmação e permitir opcionalmente ao usuário navegar para continuar.(Você deve fornecer os controles para coletar as informações exigidas pelo seu membership provider para criar uma nova conta de usuário.Para obter detalhes, consulte:CompleteWizardStep.

    O exemplo de código a seguir mostra uma propriedade CompleteStep que faz referência aos controles CheckBox do exemplo anterior.

    <asp:CompleteWizardStep ID="CompleteWizardStep1" >
        <ContentTemplate>
            <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                <tr>
                    <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d; height: 18px;">
                        Complete</td>
                </tr>
                <tr>
                    <td>
                        Your account has been successfully created.<br />
                        <br />
                        <asp:Label ID="SubscribeLabel"  Text="You have elected to receive our monthly newsletter."></asp:Label><br />
                        <br />
                        <asp:Label ID="ShareInfoLabel"  Text="You have elected to share your information with partner sites."></asp:Label></td>
                </tr>
                <tr>
                    <td align="right" colspan="2">
                        &nbsp;<asp:Button ID="ContinueButton"  BackColor="#FFFBFF" BorderColor="#CCCCCC"
                            BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
                            Font-Names="Verdana" ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:CompleteWizardStep>
    
    <asp:CompleteWizardStep ID="CompleteWizardStep1" >
        <ContentTemplate>
            <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                <tr>
                    <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d; height: 18px;">
                        Complete</td>
                </tr>
                <tr>
                    <td>
                        Your account has been successfully created.<br />
                        <br />
                        <asp:Label ID="SubscribeLabel"  Text="You have elected to receive our monthly newsletter."></asp:Label><br />
                        <br />
                        <asp:Label ID="ShareInfoLabel"  Text="You have elected to share your information with partner sites."></asp:Label></td>
                </tr>
                <tr>
                    <td align="right" colspan="2">
                        &nbsp;<asp:Button ID="ContinueButton"  BackColor="#FFFBFF" BorderColor="#CCCCCC"
                            BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
                            Font-Names="Verdana" ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:CompleteWizardStep>
    
  4. Adicione código para fazer referência a controles adicionais.Por exemplo, manipular o evento CreatingUser permite que você insira o código para coletar, verificar e modificar informações antes que seja criado uma nova conta de usuário.

    O exemplo de código a seguir mostra um manipulador para o evento CreatedUser que faz referência aos controles CheckBox de exemplos anteriores e os adiciona à propriedade Comment da conta de usuário recém-criado.Você precisará adicionar um atributo OnCreatedUser ao controle CreateUserWizard na página que faz referência ao manipulador para o evento CreatedUser (por exemplo, OnCreatedUser="CreateUserWizard1_CreatedUser".)

    Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs)
        ' Determine the checkbox values.
        Dim subscribeCheckBox As CheckBox = _
          CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox"), CheckBox)
        Dim shareInfoCheckBox As CheckBox = _
          CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox"), CheckBox)
        Dim userNameTextBox As TextBox = _
          CType(CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"), TextBox)
    
    
        Dim user As MembershipUser = Membership.GetUser(userNameTextBox.Text)
        User.Comment = "Subscribe=" & subscribeCheckBox.Checked.ToString() & "&" & _
                       "ShareInfo=" & shareInfoCheckBox.Checked.ToString()
        Membership.UpdateUser(user)
    
        ' Show or hide the labels based on the checkbox values.
        Dim subscribeLabel As Label = _
          CType(CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel"), Label)
        Dim shareInfoLabel As Label = _
          CType(CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel"), Label)
    
        subscribeLabel.Visible = subscribeCheckBox.Checked
        shareInfoLabel.Visible = shareInfoCheckBox.Checked
    End Sub
    
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
      // Determine the checkbox values.
      CheckBox subscribeCheckBox = 
        (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox");
      CheckBox shareInfoCheckBox =
        (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox");
      TextBox userNameTextBox = 
        (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName");
    
      MembershipUser user = Membership.GetUser(userNameTextBox.Text);
      user.Comment = "Subscribe=" + subscribeCheckBox.Checked.ToString() + "&" +
                     "ShareInfo=" + shareInfoCheckBox.Checked.ToString();
      Membership.UpdateUser(user);
    
      // Show or hide the labels based on the checkbox values.
      Label subscribeLabel = 
        (Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel");
      Label shareInfoLabel =
        (Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel");
    
      subscribeLabel.Visible = subscribeCheckBox.Checked;
      shareInfoLabel.Visible = shareInfoCheckBox.Checked;
    }
    

Para adicionar uma etapa assistente

  1. Adicione um elemento <asp:WizardStep> à seção <WizardSteps> do controle CreateUserWizard.Inclua quaisquer controles e marcação na etapa do assistente adicional que você personalizou que o controle CreateUserWizard irá usar.

    Por exemplo, o exemplo de código a seguir mostra uma etapa a ser adicionada antes de CreateUserStep do controle CreateUserWizard que inclui um controle de caixa de texto para que os usuários insiram um nome de usuário.O nome de usuário será selecionado para garantir que ele ainda não exista no banco de dados de associação.

    <asp:WizardStep ID="CreateUserWizardStep0" >
         <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
              <tr>
                  <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                      Select an Account Name</td>
              </tr>
              <tr>
                  <td>
                    <asp:Label ID="AccountNameLabel"  AssociatedControlID="SearchAccount" > 
                      Account Name:</asp:Label>
                    <asp:TextBox ID="SearchAccount" ></asp:TextBox><br />
                    <asp:Label ID="SearchAccountMessage"  ForeColor="red" />                                          
                  </td>
              </tr>
          </table>
     </asp:WizardStep>
    
    <asp:WizardStep ID="CreateUserWizardStep0" >
         <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
              <tr>
                  <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                      Select an Account Name</td>
              </tr>
              <tr>
                  <td>
                    <asp:Label ID="AccountNameLabel"  AssociatedControlID="SearchAccount" > 
                      Account Name:</asp:Label>
                    <asp:TextBox ID="SearchAccount" ></asp:TextBox><br />
                    <asp:Label ID="SearchAccountMessage"  ForeColor="red" />                                          
                  </td>
              </tr>
          </table>
     </asp:WizardStep>
    
  2. Adicione o código para a etapa assistente.Você pode manipular o evento NextButtonClick do controle Wizard para executar seu código.O valor da propriedade CurrentStepIndex indica que etapa adicional do assistente gerado o evento NextButtonClick pelo número de índice da etapa (começando de 0 para a primeira etapa).

    O exemplo de código a seguir mostra um manipulador para o evento NextButtonClick que leva o nome de usuário inseridos no controle TextBox na etapa do assistente a partir do exemplo de código anterior e verifica que o nome de usuário não está em branco e não existe no banco de dados de membros no momento.Você precisará adicionar um atributo OnNextButtonClick ao controle CreateUserWizard na página que faz referência ao manipulador para o manipúlador do evento NextButtonClick (por exemplo, OnNextButtonClick="CreateUserWizard1_NextButtonClick".)

    Private Function UserExists(ByVal username As String) As Boolean
        If Membership.GetUser(username) IsNot Nothing Then Return True
    
        Return False
    End Function
    
    Protected Sub CreateUserWizard1_NextButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)
        If e.CurrentStepIndex = 0 Then
            If SearchAccount.Text.Trim() = "" OrElse UserExists(SearchAccount.Text) Then
                SearchAccountMessage.Text = "That account already exists. Please select an different account name."
                e.Cancel = True
            Else
                Dim userName As TextBox = _
                  CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox)
                userName.Text = SearchAccount.Text
                SearchAccountMessage.Text = ""
                e.Cancel = False
            End If
        End If
    End Sub
    
    private bool UserExists(string username)
    {
        if (Membership.GetUser(username) != null) { return true; }
    
        return false;
    }
    
    protected void CreateUserWizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        if (e.CurrentStepIndex == 0)
        {
            if (SearchAccount.Text.Trim() == "" || UserExists(SearchAccount.Text))
            {
                SearchAccountMessage.Text = "That account already exists. Please select an different account name.";
                e.Cancel = true;
            }
            else
            {
                TextBox userName =
                  (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
                userName.Text = SearchAccount.Text;
                SearchAccountMessage.Text = "";
                e.Cancel = false;
            }
        }
    }
    
    Observação de segurança:

    Esse controle tem um caixa de texto que aceita entrada pelo usuário, que é uma ameaça potencial de segurança.Por padrão, páginas da Web ASP.NET validam a entrada do usuário para garantir que a entrada não contenha elementos HTML ou script.Para obter mais informações, consulte Visão Geral de Scripts Maliciosos.

Exemplo

O exemplo de código a seguir mostra um controle CreateUserWizard com modelos definidos para as duas etapas básicas, CreateUserStep e CompleteStep e uma etapa adicionada ao assistente antes de CreateUserStep.

Observação de segurança:

Esse controle tem um caixa de texto que aceita a entrada do usuário, o que é uma ameaça potencial de segurança.A entrada do usuário em uma página da Web pode conter script de cliente mal-intencionado.Por padrão, páginas da Web ASP.NET validam a entrada do usuário para garantir que a entrada não contenha elementos HTML ou script.Contanto que essa validação esteja ativada, não é preciso explicitamente verificar script ou elementos HTML na entrada do usuário.Para obter mais informações, consulte Visão Geral de Scripts Maliciosos.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script >
    Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs)
        ' Determine the checkbox values.
        Dim subscribeCheckBox As CheckBox = _
          CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox"), CheckBox)
        Dim shareInfoCheckBox As CheckBox = _
          CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox"), CheckBox)
        Dim userNameTextBox As TextBox = _
          CType(CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"), TextBox)


        Dim user As MembershipUser = Membership.GetUser(userNameTextBox.Text)
        User.Comment = "Subscribe=" & subscribeCheckBox.Checked.ToString() & "&" & _
                       "ShareInfo=" & shareInfoCheckBox.Checked.ToString()
        Membership.UpdateUser(user)

        ' Show or hide the labels based on the checkbox values.
        Dim subscribeLabel As Label = _
          CType(CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel"), Label)
        Dim shareInfoLabel As Label = _
          CType(CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel"), Label)

        subscribeLabel.Visible = subscribeCheckBox.Checked
        shareInfoLabel.Visible = shareInfoCheckBox.Checked
    End Sub

    Private Function UserExists(ByVal username As String) As Boolean
        If Membership.GetUser(username) IsNot Nothing Then Return True

        Return False
    End Function

    Protected Sub CreateUserWizard1_NextButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)
        If e.CurrentStepIndex = 0 Then
            If SearchAccount.Text.Trim() = "" OrElse UserExists(SearchAccount.Text) Then
                SearchAccountMessage.Text = "That account already exists. Please select an different account name."
                e.Cancel = True
            Else
                Dim userName As TextBox = _
                  CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox)
                userName.Text = SearchAccount.Text
                SearchAccountMessage.Text = ""
                e.Cancel = False
            End If
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" >
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" >
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1"  BackColor="#F7F6F3" BorderColor="#E6E2D8"
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" 
            OnNextButtonClick="CreateUserWizard1_NextButtonClick"
            OnCreatedUser="CreateUserWizard1_CreatedUser" ContinueDestinationPageUrl="~/Default.aspx">
            <WizardSteps>
               <asp:WizardStep ID="CreateUserWizardStep0" >
                    <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                         <tr>
                             <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                                 Select an Account Name</td>
                         </tr>
                         <tr>
                             <td>
                               <asp:Label ID="AccountNameLabel"  AssociatedControlID="SearchAccount" > 
                                 Account Name:</asp:Label>
                               <asp:TextBox ID="SearchAccount" ></asp:TextBox><br />
                               <asp:Label ID="SearchAccountMessage"  ForeColor="red" />                                          
                             </td>
                         </tr>
                     </table>
                </asp:WizardStep>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep1" >
                    <ContentTemplate>
                        <table border="0" style="font-size: 100%; font-family: Verdana">
                            <tr>
                                <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                                    Sign Up for Your New Account</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel"  AssociatedControlID="UserName">
                                        User Name:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="UserName" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired"  ControlToValidate="UserName"
                                        ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="PasswordLabel"  AssociatedControlID="Password">
                                        Password:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Password"  TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired"  ControlToValidate="Password"
                                        ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="ConfirmPasswordLabel"  AssociatedControlID="ConfirmPassword">
                                        Confirm Password:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="ConfirmPassword"  TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="ConfirmPasswordRequired"  ControlToValidate="ConfirmPassword"
                                        ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="EmailLabel"  AssociatedControlID="Email">
                                        E-mail:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Email" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="EmailRequired"  ControlToValidate="Email"
                                        ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="QuestionLabel"  AssociatedControlID="Question">
                                        Security Question:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Question" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="QuestionRequired"  ControlToValidate="Question"
                                        ErrorMessage="Security question is required." ToolTip="Security question is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="AnswerLabel"  AssociatedControlID="Answer">
                                        Security Answer:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Answer" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="AnswerRequired"  ControlToValidate="Answer"
                                        ErrorMessage="Security answer is required." ToolTip="Security answer is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <asp:CompareValidator ID="PasswordCompare"  ControlToCompare="Password"
                                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                        ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color: red">
                                    <asp:Literal ID="ErrorMessage"  EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                        </table>
                        <asp:CheckBox ID="SubscribeCheckBox"  Checked="True" Text="Send me a monthly newsletter." />
                        <br />
                        <asp:CheckBox ID="ShareInfoCheckBox"  Checked="True" Text="Share my information with partner sites." />
                    </ContentTemplate>
                </asp:CreateUserWizardStep>
                <asp:CompleteWizardStep ID="CompleteWizardStep1" >
                    <ContentTemplate>
                        <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                            <tr>
                                <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d; height: 18px;">
                                    Complete</td>
                            </tr>
                            <tr>
                                <td>
                                    Your account has been successfully created.<br />
                                    <br />
                                    <asp:Label ID="SubscribeLabel"  Text="You have elected to receive our monthly newsletter."></asp:Label><br />
                                    <br />
                                    <asp:Label ID="ShareInfoLabel"  Text="You have elected to share your information with partner sites."></asp:Label></td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    &nbsp;<asp:Button ID="ContinueButton"  BackColor="#FFFBFF" BorderColor="#CCCCCC"
                                        BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
                                        Font-Names="Verdana" ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" />
                                </td>
                            </tr>
                        </table>
                    </ContentTemplate>
                </asp:CompleteWizardStep>
            </WizardSteps>
            <SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" VerticalAlign="Top" />
            <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
            <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" Font-Size="0.9em"
                ForeColor="White" HorizontalAlign="Center" />
            <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <StepStyle BorderWidth="0px" />
        </asp:CreateUserWizard>
        &nbsp;</div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script >
  protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
  {
    // Determine the checkbox values.
    CheckBox subscribeCheckBox = 
      (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox");
    CheckBox shareInfoCheckBox =
      (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox");
    TextBox userNameTextBox = 
      (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName");

    MembershipUser user = Membership.GetUser(userNameTextBox.Text);
    user.Comment = "Subscribe=" + subscribeCheckBox.Checked.ToString() + "&" +
                   "ShareInfo=" + shareInfoCheckBox.Checked.ToString();
    Membership.UpdateUser(user);

    // Show or hide the labels based on the checkbox values.
    Label subscribeLabel = 
      (Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel");
    Label shareInfoLabel =
      (Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel");

    subscribeLabel.Visible = subscribeCheckBox.Checked;
    shareInfoLabel.Visible = shareInfoCheckBox.Checked;
  }

  private bool UserExists(string username)
  {
      if (Membership.GetUser(username) != null) { return true; }

      return false;
  }

  protected void CreateUserWizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
  {
      if (e.CurrentStepIndex == 0)
      {
          if (SearchAccount.Text.Trim() == "" || UserExists(SearchAccount.Text))
          {
              SearchAccountMessage.Text = "That account already exists. Please select an different account name.";
              e.Cancel = true;
          }
          else
          {
              TextBox userName =
                (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
              userName.Text = SearchAccount.Text;
              SearchAccountMessage.Text = "";
              e.Cancel = false;
          }
      }
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" >
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" >
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1"  BackColor="#F7F6F3" BorderColor="#E6E2D8"
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" 
            OnNextButtonClick="CreateUserWizard1_NextButtonClick"
            OnCreatedUser="CreateUserWizard1_CreatedUser" ContinueDestinationPageUrl="~/Default.aspx">
            <WizardSteps>
               <asp:WizardStep ID="CreateUserWizardStep0" >
                    <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                         <tr>
                             <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                                 Select an Account Name</td>
                         </tr>
                         <tr>
                             <td>
                               <asp:Label ID="AccountNameLabel"  AssociatedControlID="SearchAccount" > 
                                 Account Name:</asp:Label>
                               <asp:TextBox ID="SearchAccount" ></asp:TextBox><br />
                               <asp:Label ID="SearchAccountMessage"  ForeColor="red" />                                          
                             </td>
                         </tr>
                     </table>
                </asp:WizardStep>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep1" >
                    <ContentTemplate>
                        <table border="0" style="font-size: 100%; font-family: Verdana">
                            <tr>
                                <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                                    Sign Up for Your New Account</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel"  AssociatedControlID="UserName">
                                        User Name:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="UserName" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired"  ControlToValidate="UserName"
                                        ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="PasswordLabel"  AssociatedControlID="Password">
                                        Password:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Password"  TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired"  ControlToValidate="Password"
                                        ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="ConfirmPasswordLabel"  AssociatedControlID="ConfirmPassword">
                                        Confirm Password:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="ConfirmPassword"  TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="ConfirmPasswordRequired"  ControlToValidate="ConfirmPassword"
                                        ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="EmailLabel"  AssociatedControlID="Email">
                                        E-mail:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Email" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="EmailRequired"  ControlToValidate="Email"
                                        ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="QuestionLabel"  AssociatedControlID="Question">
                                        Security Question:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Question" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="QuestionRequired"  ControlToValidate="Question"
                                        ErrorMessage="Security question is required." ToolTip="Security question is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="AnswerLabel"  AssociatedControlID="Answer">
                                        Security Answer:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Answer" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="AnswerRequired"  ControlToValidate="Answer"
                                        ErrorMessage="Security answer is required." ToolTip="Security answer is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <asp:CompareValidator ID="PasswordCompare"  ControlToCompare="Password"
                                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                        ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color: red">
                                    <asp:Literal ID="ErrorMessage"  EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                        </table>
                        <asp:CheckBox ID="SubscribeCheckBox"  Checked="True" Text="Send me a monthly newsletter." />
                        <br />
                        <asp:CheckBox ID="ShareInfoCheckBox"  Checked="True" Text="Share my information with partner sites." />
                    </ContentTemplate>
                </asp:CreateUserWizardStep>
                <asp:CompleteWizardStep ID="CompleteWizardStep1" >
                    <ContentTemplate>
                        <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                            <tr>
                                <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d; height: 18px;">
                                    Complete</td>
                            </tr>
                            <tr>
                                <td>
                                    Your account has been successfully created.<br />
                                    <br />
                                    <asp:Label ID="SubscribeLabel"  Text="You have elected to receive our monthly newsletter."></asp:Label><br />
                                    <br />
                                    <asp:Label ID="ShareInfoLabel"  Text="You have elected to share your information with partner sites."></asp:Label></td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    &nbsp;<asp:Button ID="ContinueButton"  BackColor="#FFFBFF" BorderColor="#CCCCCC"
                                        BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
                                        Font-Names="Verdana" ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" />
                                </td>
                            </tr>
                        </table>
                    </ContentTemplate>
                </asp:CompleteWizardStep>
            </WizardSteps>
            <SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" VerticalAlign="Top" />
            <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
            <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" Font-Size="0.9em"
                ForeColor="White" HorizontalAlign="Center" />
            <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <StepStyle BorderWidth="0px" />
        </asp:CreateUserWizard>
        &nbsp;</div>
    </form>
</body>
</html>

Consulte também

Conceitos

Personalizando a Aparência dos Controles de Login do ASP.NET

Visão Geral de Temas e Aparências ASP.NET

Referência

Visão Geral sobre Controles de Login ASP.NET

TemplatedWizardStep