CreateUserWizard.CreatedUser Evento

Definição

Ocorre depois que o provedor de associação criou a nova conta de usuário do site.

public:
 event EventHandler ^ CreatedUser;
public event EventHandler CreatedUser;
member this.CreatedUser : EventHandler 
Public Custom Event CreatedUser As EventHandler 

Tipo de evento

Exemplos

O exemplo de código a seguir usa o CreatedUser evento para armazenar o nome e o sobrenome do usuário em propriedades de personalização. O exemplo de código requer as seguintes entradas no arquivo Web.config.

<configuration>

<system.web>

<profile>

<properties>

<add name="lastName" />

<add name="firstName" />

<add name="userName" />

</properties>

</profile>

</system.web>

</configuration>

<%@ page language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
  Profile.SetPropertyValue("userName",firstName.Text + " " + lastName.Text);  
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      CreateUserWizard.CreatedUser sample</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:createuserwizard id="CreateUserWizard1" 
                              oncreateduser="CreateUserWizard1_CreatedUser"
                              runat="server">
          <wizardsteps>
            <asp:wizardstep runat="server" steptype="Start" title="Identification">
              Tell us your name:<br />
              <table width="100%">
                <tr>
                  <td>
                    First name:</td>
                  <td>
                    <asp:textbox id="firstName" runat="server" /></td>
                </tr>
                <tr>
                  <td>
                    Last name:</td>
                  <td>
                    <asp:textbox id="lastName" runat="server" /></td>
                </tr>
              </table>
            </asp:wizardstep>
            <asp:createuserwizardstep runat="server" title="Sign Up for Your New Account">
            </asp:createuserwizardstep>
          </wizardsteps>
        </asp:createuserwizard>
      </div>
    </form>
  </body>
</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 runat="server">

  Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)
    Profile.SetPropertyValue("userName", firstName.Text & " " & lastName.Text)
  End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      CreateUserWizard.CreatedUser sample</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:createuserwizard id="CreateUserWizard1"
                              oncreateduser="CreateUserWizard1_CreatedUser"
                              runat="server">
          <wizardsteps>
            <asp:wizardstep runat="server" steptype="Start" title="Identification">
              Tell us your name:<br />
              <table width="100%">
                <tr>
                  <td>
                    First name:</td>
                  <td>
                    <asp:textbox id="firstName" runat="server" /></td>
                </tr>
                <tr>
                  <td>
                    Last name:</td>
                  <td>
                    <asp:textbox id="lastName" runat="server" /></td>
                </tr>
              </table>
            </asp:wizardstep>
            <asp:createuserwizardstep runat="server" title="Sign Up for Your New Account">
            </asp:createuserwizardstep>
          </wizardsteps>
        </asp:createuserwizard>
      </div>
    </form>
  </body>
</html>

Importante

Este exemplo tem uma caixa de texto que aceita a entrada do usuário, que é uma possível ameaça à segurança. Por padrão, ASP.NET páginas da Web validam que a entrada do usuário não inclui elementos HTML ou script. Para obter mais informações, consulte Visão geral de explorações de script.

Comentários

O CreatedUser evento é gerado depois que o provedor de associação especificado na MembershipProvider propriedade cria a nova conta de usuário do site. Se a LoginCreatedUser propriedade for true, o usuário será conectado ao site após o CreatedUser evento.

Use o CreatedUser evento para definir valores de site, como valores de personalização, antes que o usuário seja conectado ao site pela primeira vez.

Para obter mais informações sobre como lidar com eventos, consulte Manipulando e levantando eventos.

Aplica-se a

Confira também