CreateUserWizard.CreatedUser Evento
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Ocorre depois de o fornecedor de membros ter criado a nova conta de utilizador 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 seguinte utiliza o CreatedUser evento para armazenar o primeiro e apelido do utilizador nas propriedades de personalização. O exemplo de código requer as seguintes entradas no ficheiro 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 utilizador, o que constitui uma potencial ameaça à segurança. Por defeito, as páginas Web do ASP.NET validam que a entrada do utilizador não inclui elementos de script ou HTML. Para mais informações, consulte Visão Geral dos Exploits de Scripts.
Observações
O CreatedUser evento é levantado depois de o fornecedor de membros especificado na MembershipProvider propriedade criar a nova conta de utilizador do site. Se a LoginCreatedUser propriedade for true, o utilizador fica ligado ao site após o CreatedUser evento.
Use o CreatedUser evento para definir valores do site, como valores de personalização, antes de o utilizador iniciar sessão no site pela primeira vez.
Para obter mais informações sobre como manipular eventos, consulte Manipulando e gerando eventos.