CreateUserWizard.CreatedUser Event

Definition

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 

Event Type

Examples

The following code example uses the CreatedUser event to store the user's first and last name in personalization properties. 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>

Important

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

Remarks

The CreatedUser event is raised after the membership provider specified in the MembershipProvider property creates the new Web site user account. If the LoginCreatedUser property is true, the user is logged on to the Web site after the CreatedUser event.

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.

Applies to

See also