CreateUserWizard.CreatedUser Zdarzenie

Definicja

Występuje po utworzeniu nowego konta użytkownika witryny sieci Web przez dostawcę członkostwa.

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

Typ zdarzenia

Przykłady

Poniższy przykład kodu używa CreatedUser zdarzenia do przechowywania imienia i nazwiska użytkownika we właściwościach personalizacji. Przykładowy kod wymaga następujących wpisów w pliku 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>

Ważne

Ten przykład zawiera pole tekstowe, które akceptuje dane wejściowe użytkownika, co jest potencjalnym zagrożeniem bezpieczeństwa. Domyślnie ASP.NET strony sieci Web sprawdzają, czy dane wejściowe użytkownika nie zawierają skryptów ani elementów HTML. Aby uzyskać więcej informacji, zobacz Script Exploits Overview (Omówienie luk w zabezpieczeniach skryptów).

Uwagi

Zdarzenie CreatedUser jest wywoływane po tym, jak dostawca członkostwa określony we MembershipProvider właściwości tworzy nowe konto użytkownika witryny sieci Web. LoginCreatedUser Jeśli właściwość to true, użytkownik jest zalogowany do witryny sieci Web po zdarzeniuCreatedUser.

CreatedUser Użyj zdarzenia, aby ustawić wartości witryny sieci Web, takie jak wartości personalizacji, zanim użytkownik zostanie zalogowany do witryny po raz pierwszy.

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Dotyczy

Zobacz też