CreateUserWizard.CreatedUser 事件
定义
在成员资格提供程序创建了新的网站用户帐户后发生。Occurs after the membership provider has created the new Web site user account.
public:
event EventHandler ^ CreatedUser;
public event EventHandler CreatedUser;
member this.CreatedUser : EventHandler
Public Custom Event CreatedUser As EventHandler
事件类型
示例
下面的代码示例使用 CreatedUser 事件在个性化属性中存储用户的名字和姓氏。The following code example uses the CreatedUser event to store the user's first and last name in personalization properties. 此代码示例需要 Web.config 文件中的以下条目。The code example requires the following entries in the Web.config file.
<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>
重要
此示例具有一个接受用户输入的文本框,这是一个潜在的安全威胁。This example has a text box that accepts user input, which is a potential security threat. 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 有关详细信息,请参阅脚本侵入概述。For more information, see Script Exploits Overview.
注解
此 CreatedUser 事件在属性中指定的成员资格提供程序 MembershipProvider 创建新的网站用户帐户后引发。The CreatedUser event is raised after the membership provider specified in the MembershipProvider property creates the new Web site user account. 如果 LoginCreatedUser 属性为 true ,则用户将在事件之后登录到网站 CreatedUser 。If the LoginCreatedUser property is true, the user is logged on to the Web site after the CreatedUser event.
在 CreatedUser 用户首次登录到站点之前,使用事件设置网站值(如个性化设置值)。Use the CreatedUser event to set Web site values, such as personalization values, before the user is logged on to the site for the first time.
有关处理事件的详细信息,请参阅 处理和引发事件。For more information about handling events, see Handling and Raising Events.