Question

I want to make a function to register a new user without using CreateUserWizard. How could I change my code to allow this?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="registerUser.aspx.cs" Inherits="_Default" %>

<html>
  <head runat="server">
    <title>LLLY网上书店 - 注册</title>
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>
    <div class="container">
      <section class="register">
        <h1>LLLY网上书店 - 注册新用户</h1>
        <form method="post" action="index.html" runat="server">
          <div class="reg_section personal_info">
            <h3>个人信息</h3>
            <asp:TextBox ID="username" runat="server" value="" placeholder="用户名"></asp:TextBox>
            <asp:TextBox ID="email" runat="server" placeholder="电子邮件地址"></asp:TextBox>
          </div>
          <div class="reg_section password">
            <h3>用户密码</h3>
            <asp:TextBox ID="password" runat="server" placeholder="请输入密码"></asp:TextBox>
            <asp:TextBox ID="confirmPwd" runat="server" placeholder="确认密码"></asp:TextBox>
            <input type="password" name="confirm" value="" placeholder="确认密码">--%>
          </div>
          <div class="reg_section password">
            <h3>地区</h3>
            <asp:DropDownList ID="DropDownList1" runat="server">
              <asp:ListItem>1</asp:ListItem>
              <asp:ListItem>2</asp:ListItem>
              <asp:ListItem>3</asp:ListItem>
            </asp:DropDownList>
            <asp:TextBox ID="textarea" runat="server" TextMode="MultiLine" placeholder="家庭住址"></asp:TextBox>
          </div>
          <p class="terms">
            <label>
              <input type="checkbox" name="remember_me" id="remember_me">
              我同意  <a href="http://www.imomen.com/">LLLY网上书店</a>&nbsp;注册准入原则
              </label>
          </p>
          <p class="submit">
            <asp:Button ID="commit" runat="server" Text="注册" onclick="commit_Click"></asp:Button>
          </p>
        </form>
      </section>
    </div>
  </body>
</html>
Was it helpful?

Solution

Your question is not so simple and you can find a fully tutorial with source code and details on asp.net site:

Creating User Accounts (C#)

Also you can read the article about:Understanding ASP.NET Roles and Membership - A Beginner's Tutorial

OTHER TIPS

If you want to create user by code you can use one of overload method of Create User in Membership class.

MSDN : Membership.CreateUser Method

MembershipCreateStatus status;
var user = Membership.CreateUser(username.Text, password.Text, email.Text, null, null, true, out status);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top