Export (0) Print
Expand All
Expand Minimize

CreateUserWizard.MembershipProvider Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the membership provider called to create user accounts.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[ThemeableAttribute(false)] 
public virtual string MembershipProvider { get; set; }
/** @property */
public String get_MembershipProvider ()

/** @property */
public void set_MembershipProvider (String value)

public function get MembershipProvider () : String

public function set MembershipProvider (value : String)

Property Value

The MembershipProvider used to create user accounts. The default is Empty.

Exception typeCondition

HttpException

The specified membership provider is not defined in the Web.config file.

The MembershipProvider property contains the name of the defined MembershipProvider class membership provider that is used to store the user information. You can store membership information for users in different data stores by changing the value of the MembershipProvider property. When the MembershipProvider property is set to Empty, the default membership provider defined in the Web.config file is used.

Membership providers are defined in the Web.config file in the <membership> section.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins Overview.

The following code example requires membership providers defined in the <membership> section of the Web.config file. The following is a Web.config file that defines membership providers for each division in a small company. For this example, each membership provider points to a SQL Server database.

<configuration>

<system.web>

<membership>

<providers>

<add name="accountingProvider"

type="System.Web.Security.SqlMembershipProvider,

System.Web, Version=2.0.3600.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="LocalSqlServer"

enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="false"

applicationName="/"

requiresUniqueEmail="false"

passwordFormat="Hashed"

description="Stores and retrieves membership data from a Microsoft SQL Server database."

/>

<add name="manufacturingProvider"

type="System.Web.Security. SqlMembershipProvider,

System.Web, Version=2.0.3600.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="LocalSqlServer"

enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="false"

applicationName="/"

requiresUniqueEmail="false"

passwordFormat="Hashed"

description="Stores and retrieves membership data from a Microsoft SQL Server database."

/>

<add name="marketingProvider"

type="System.Web.Security. SqlMembershipProvider,

System.Web, Version=2.0.3600.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="LocalSqlServer"

enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="false"

applicationName="/"

requiresUniqueEmail="false"

passwordFormat="Hashed"

description="Stores and retrieves membership data from a Microsoft SQL Server database."

/>

<add name="salesProvider"

type="System.Web.Security. SqlMembershipProvider,

System.Web, Version=2.0.3600.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="LocalSqlServer"

enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="false"

applicationName="/"

requiresUniqueEmail="false"

passwordFormat="Hashed"

description="Stores and retrieves membership data from a Microsoft SQL Server database."

/>

</providers>

</membership>

</system.web>

</configuration>

The following code example inserts a step before the user account is created to determine which division of an organization the user belongs to. It then sets the MembershipProvider provider to the appropriate provider for that division.

<%@ page language="C#"%>
<script runat="server">
  
  void Createuserwizard1_NextButtonClick(object sender, EventArgs e)
  {
    if (Createuserwizard1.ActiveStepIndex==0)
    {
      Createuserwizard1.MembershipProvider =
        divisionList.SelectedValue;
      Createuserwizard1.CreateUserStep.Title =
        String.Format("Create your new {0} account.",
          divisionList.SelectedItem.Text);
    }
  }
</script>

<html>
  <head runat="server">
    <title>
      Untitled Page</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:createuserwizard id="Createuserwizard1" runat="server" onnextbuttonclick="Createuserwizard1_NextButtonClick">
          <wizardsteps>
            <asp:wizardstep runat="server" title="Choose your division">
              <p>
                Choose your division and click "Next".</p>
              <asp:dropdownlist runat="server" id="divisionList">
                <asp:listitem value="accountingProvider">
                  Accounting</asp:listitem>
                <asp:listitem value="manufacturingProvider">
                  Manufacturing</asp:listitem>
                <asp:listitem value="marketingProvider">
                  Marketing</asp:listitem>
                <asp:listitem value="salesProvider">
                  Sales</asp:listitem>
              </asp:dropdownlist>
            </asp:wizardstep>
            <asp:createuserwizardstep runat="server" title="Sign Up for Your New Account">
            </asp:createuserwizardstep>
          </wizardsteps>
        </asp:createuserwizard>
      </div>
    </form>
  </body>
</html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft