CreateUserWizard.CreatedUser 事件

定义

在成员资格提供程序创建了新的网站用户帐户后发生。

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

事件类型

示例

下面的代码示例使用 CreatedUser 事件将用户的名字和姓氏存储在个性化属性中。 该代码示例要求在 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>

重要

此示例具有一个接受用户输入的文本框,这是一个潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅脚本侵入概述

注解

CreatedUser 属性中指定的 MembershipProvider 成员资格提供程序创建新的网站用户帐户后,将引发 该事件。 LoginCreatedUser如果 属性为 true,则用户将在 事件发生后CreatedUser登录到网站。

CreatedUser 用户首次登录到网站之前,使用 事件设置网站值,例如个性化设置值。

有关处理事件的详细信息,请参阅 处理和引发事件

适用于

另请参阅