다음을 통해 공유


방법: ASP.NET CreateUserWizard 컨트롤 사용자 지정

업데이트: 2007년 11월

CreateUserWizardStepCompleteWizardStep 템플릿을 사용하여 CreateUserWizard 컨트롤의 내용을 사용자 지정할 수 있습니다. 템플릿의 내용을 지정하여 고유의 사용자 지정 UI(사용자 인터페이스)를 지정할 수 있습니다. 이 UI에는 CreateUserWizard 컨트롤에서 새 사용자에 대한 정보를 수집하는 데 사용하는 컨트롤뿐 아니라 사용자가 지정하는 추가 컨트롤이 포함될 수 있습니다. CreateUserWizard 컨트롤에서 사용하는 컨트롤의 목록은 ASP.NET Login 컨트롤 모양 사용자 지정을 참조하십시오.

또한 CreateUserWizard 컨트롤은 Wizard 클래스에서 상속하므로 CreateUserWizard 컨트롤에 고유의 사용자 지정 단계를 추가할 수 있습니다. Wizard 컨트롤에 대한 자세한 내용은 Wizard 웹 서버 컨트롤 개요를 참조하십시오.

참고:

테마와 스타일 속성을 사용하여 CreateUserWizard 컨트롤의 모양을 사용자 지정할 수도 있습니다. 자세한 내용은 ASP.NET 테마 및 스킨 개요CreateUserWizard 컨트롤의 속성을 참조하십시오.

CreateUserWizard 단계를 사용자 지정하려면

  1. 다음 구문을 사용하여 CreateUserWizard 컨트롤을 페이지에 배치합니다.

    <asp:CreateUserWizard ID="CreateUserWizard1" Runat="server">
      <WizardSteps>
        <asp:CreateUserWizardStep >
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep >
        </asp:CompleteWizardStep>
      </WizardSteps>
    </asp:CreateUserWizard>
    
  2. 사용자 계정 만들기 단계를 사용자 지정하려면 <asp:CreateUserWizardStep> 요소 내에 <ContentTemplate> 요소를 만듭니다. 그런 다음 필요한 사용자 정보를 수집하는 데 사용할 UI의 레이아웃과 내용을 정의하는 컨트롤과 태그를 템플릿에 추가합니다.

    참고:

    멤버 자격 공급자가 사용자 지정 멤버로 MembershipProvider 클래스를 확장할 경우에는 새 사용자를 만들기 위해 멤버 자격 공급자에 필요한 사용자 지정 정보를 수집하는 컨트롤을 추가해야 합니다. 자세한 내용은 CreateUserWizardStep을 참조하십시오.

    다음 코드 예제에서는 사용자가 추가 옵션을 지정할 수 있는 CheckBox 컨트롤이 포함된 CreateUserStep 속성을 보여 줍니다.

    <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. 완료 단계를 사용자 지정하려면 <asp:CompleteWizardStep> 요소 내에 <ContentTemplate> 요소를 만듭니다. 그런 다음 확인 메시지를 표시하고 필요에 따라 사용자가 계속 탐색할 수 있도록 하는 데 사용할 UI의 레이아웃과 내용을 정의하는 컨트롤과 태그를 템플릿에 추가합니다. 새 사용자 계정을 만들기 위해 멤버 자격 공급자에 필요한 정보를 수집할 수 있도록 컨트롤을 제공해야 합니다. 자세한 내용은 CompleteWizardStep을 참조하십시오.

    다음 코드 예제에서는 이전 예제의 CheckBox 컨트롤을 참조하는 CompleteStep 속성을 보여 줍니다.

    <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. 추가 컨트롤을 참조하는 코드를 추가합니다. 예를 들어, CreatingUser 이벤트를 처리하면 새 사용자 계정을 만들기 전에 정보를 수집, 확인 및 수정하기 위한 코드를 입력할 수 있습니다.

    다음 코드 예제에서는 이전 예제의 CheckBox 컨트롤을 참조하고 이 컨트롤을 새로 만든 사용자 계정의 Comment 속성에 추가하는 CreatedUser 이벤트에 대한 처리기를 보여 줍니다. 페이지에서 CreatedUser 이벤트의 처리기를 참조하는 CreateUserWizard 컨트롤에 OnCreatedUser 특성을 추가해야 합니다(예: 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;
    }
    

마법사 단계를 추가하려면

  1. <asp:WizardStep> 요소를 CreateUserWizard 컨트롤의 <WizardSteps> 섹션에 추가합니다. 사용자 지정한 CreateUserWizard 컨트롤에서 사용할 모든 컨트롤과 태그를 추가 마법사 단계에 포함시킵니다.

    예를 들어, 다음 코드 예제에서는 CreateUserWizard 컨트롤의 CreateUserStep 앞에 추가하는 단계를 보여 주는데, 이 단계에는 사용자가 사용자 이름을 입력할 수 있는 텍스트 상자 컨트롤이 들어 있습니다. 입력한 사용자 이름을 검사하여 멤버 자격 데이터베이스에 이미 있지 않은지 확인합니다.

    <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. 마법사 단계의 코드를 추가합니다. Wizard 컨트롤의 NextButtonClick 이벤트를 처리하여 코드를 실행할 수 있습니다. CurrentStepIndex 속성 값은 NextButtonClick 이벤트를 발생시킨 추가 마법사 단계를 단계 인덱스 번호(첫 단계가 0임)로 나타냅니다.

    다음 코드 예제에서는 NextButtonClick 이벤트에 대한 처리기를 보여 줍니다. 이 처리기는 이전 코드 예제의 마법사 단계에서 TextBox 컨트롤에 입력된 사용자 이름을 가져오고 사용자 이름이 비어 있거나 멤버 자격 데이터베이스에 이미 들어 있지 않은지 확인합니다. 페이지에서 NextButtonClick 이벤트 처리기에 대한 처리기를 참조하는 CreateUserWizard 컨트롤에 OnNextButtonClick 특성을 추가해야 합니다(예: 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;
            }
        }
    }
    
    보안 정보:

    이 컨트롤에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 ASP.NET 웹 페이지에서는 사용자 입력의 유효성을 검사하여 입력에 HTML 요소나 스크립트가 포함되지 않도록 합니다. 자세한 내용은 스크립트 악용 개요를 참조하십시오.

예제

다음 코드 예제에서는 CreateUserStepCompleteStep이라는 두 가지 기본 단계에 대한 템플릿이 정의된 CreateUserWizard 컨트롤과 CreateUserStep 앞에 추가된 추가 마법사 단계를 보여 줍니다.

보안 정보:

이 컨트롤에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 웹 페이지의 사용자 입력에는 악의적인 클라이언트 스크립트가 포함될 수 있습니다. 기본적으로 ASP.NET 웹 페이지에서는 사용자 입력의 유효성을 검사하여 입력에 HTML 요소나 스크립트가 포함되지 않도록 합니다. 이러한 유효성 검사를 사용하는 경우에는 사용자 입력에서 스크립트 또는 HTML 요소를 명시적으로 검사할 필요가 없습니다. 자세한 내용은 스크립트 악용 개요를 참조하십시오.

<%@ 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>

참고 항목

개념

ASP.NET Login 컨트롤 모양 사용자 지정

ASP.NET 테마 및 스킨 개요

참조

ASP.NET Login 컨트롤 개요

TemplatedWizardStep