`

2、使用CreateUserWizard控件

阅读更多
使用CreateUserWizard控件

CreateUserWizard输出一个用户注册表单,那么一个新用户将添加到网站中。在后台,CreateUserWizard控件使用Asp.netMemebership来创建新用户

ShowCreateUserWizard.aspx
<%@ 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">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style type="text/css">
        .createUser
        {
            width: 350px;
            font: 14px Verdana,Sans-Serif;
            background-color: lightBlue;
            border: solid 3px black;
            padding: 4px;
        }
        .createUser_title
        {
            background-color: darkblue;
            color: White;
            font-weight: bold;
        }
        .createUser_instructions
        {
            font-size: 12px;
            text-align: left;
            padding: 10px;
        }
        .createUser_button
        {
            border: solid 1px black;
            padding: 3px;
        }
    </style>
    <title>Show CreateUserWizard</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1" ContinueDestinationPageUrl="~/Default.aspx"
            InstructionText="Please complete the following from to register at this Website."
            CompleteSuccessText="Your new account has been created. Thank you for registering."
            CssClass="createUser" TitleTextStyle-CssClass="createUser_title" InstructionTextStyle-CssClass="createUser_instructions"
            CreateUserButtonStyle-CssClass="createUser_button" ContinueButtonStyle-CssClass="createUser_button"
            runat="server" />
    </div>
    </form>
</body>
</html>


1、配置自定义用户表单字段

Web.Config
<?xml version="1.0"?>
<!--
  有®D关?如¨?何?配?置? ASP.NET 应®|用®?程¨¬序¨°的Ì?详¨º细?信?息¡é,ê?请?访¤?问¨º
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <authentication mode="Forms"/>
    <membership defaultProvider="MyMembership">
      <providers>
        <add name="MyMembership" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer"
              requiresQuestionAndAnswer="false" requiresUniqueEmail="false"        />
      </providers>
    </membership>

  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>


精简版的
CreateUserWizardShort.aspx
<%@ 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">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>CreateUserWizard Short</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1" RequireEmail="false" runat="server" />
    </div>
    </form>
</body>
</html>


2、发送已创建用户电子邮件通知
注册新用户后自动发送电子邮件通知。
CreateUserWizardEmail.aspx
<%@ 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">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Create Wizard Email</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
            <MailDefinition BodyFileName="Register.txt" Subject="Registration Confirmation" From="wayhua@126.com" />
        </asp:CreateUserWizard>
    </div>
    </form>
</body>
</html>


Register.txt
Thank you for registering!
Here is your new username and password;
Username:<% UserName %>
Password:<% Password %>


Web.Config配置文件
<configuration>
  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.net>
    <mailSettings>
      <smtp>
        <network  host="smtp.126.com" userName="wayhua" password="***"/>
      </smtp>
    </mailSettings>
  </system.net>
....


3、用户自动重定向来源页面
当用户通过页面Login.aspx中的表单成功登录后,将会自动重定向回其请求的来源页面。

4、自动生成密码
自动生成密码
CreateUserWizardPasswordConfirmation.aspx
<%@ 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">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1" CompleteSuccessText="A confirmation email containing your new password has been sent to your email address"
            AutoGeneratePassword="true" LoginCreatedUser="false" ContinueDestinationPageUrl="~/LoginReturn.aspx"
            runat="server">
            <MailDefinition From="wayhua@126.com" BodyFileName="PasswordConfirmation.htm" IsBodyHtml="true"
                Subject="Registration confirmation" />
        </asp:CreateUserWizard>
    </div>
    </form>
</body>
</html>


PasswordConfirmation.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Password Confirmation</title>
</head>
<body>
    Your new password is
    <% Password %>
</body>
</html>


用户自己选择密码,确认前不可用。发送邮件确认后方可用

5、在CreateUserWizard控件中使用模板
6、在CreateUserWizard控件中添加注册步骤
P36-P40
2011-5-3  14:32:08 danny
分享到:
评论

相关推荐

    19 使用Login控件和CreateUserWizard控件实现用户注册与登录.exe

    19 使用Login控件和CreateUserWizard控件实现用户注册与登录.exe

    asp.net高级Web服务器控件

    实例 CreateUserWizard控件创建新用户登录 6.4 日期与时间 实例 通过Calendar控件查看指定日期新闻 实例 制作万年历 实例 日历备忘录 6.5 用WebPart实现个性化 实例 创建简单的WebPart页 实例 在WebPart中加入用户...

    ASP.NET 3.5 揭秘(卷2).part2

     1.3 使用CreateUserWizard控件  1.4 使用LoginStatus控件  1.5 使用LoginName控件  1.6 使用ChangePassword控件  1.7 使用PasswordRecovery控件  1.8 使用LoginView控件  1.9 小结  第2章 使用ASP...

    asp.net 图片验证 例子

    1CreateUserWizard控件属性非常多,如何使用CreateUserWizard控件: CreateUserWizard控件会输出一个用户注册表单。如果用户成功提交了该表单,那么一个新用户将添加到网站中。在后台,CreateUserWizard控件使用ASP...

    ASP.NET3.5揭秘(卷2)part1

     1.3 使用CreateUserWizard控件  1.4 使用LoginStatus控件  1.5 使用LoginName控件  1.6 使用ChangePassword控件  1.7 使用PasswordRecovery控件  1.8 使用LoginView控件  1.9 小结  第2章 使用ASP...

    [ASP.NET.4揭秘(卷2)].(.ASP.NET.4.Unleashed).谭振林等

    出版社: 人民邮电出版社; 第1版 (2011年4月1日) 外文书名: ASP.NET 4 Unleashed 丛书名: 图灵程序设计丛书 ...1.3.5 在CreateUserWizard控件中使用模板 1.3.6 在CreateUserWizard控件中添加注册步骤

    ASP.NET登陆控件最全最详细介绍

    ASP.NET登录控件概述Login控件LoginView 控件LoginStatus 控件LoginName 控件PasswordRecovery 控件CreateUserWizard 控件ChangePassword 控件 Login系列控件是微软为了简化我们的开发过程,为我们进行常规的安全...

    ASP.NET.4揭秘 卷2

    n13 使用CreateUserWizard控件 n131 配置自定义用户表单字段 n132 发送已创建用户电子邮件通知 n133 用户自动重定向来源页面 n134 自动生成密码 n135 在CreateUserWizard控件中使用模板 n136 在CreateUserWizard控件...

    ASP.NET2.0中的登陆控件简介(3)

    CreateUserWizard控件 使用该控件,可以很方便地一步步引导用户进行注册。拖拉其到设计窗体中,如下图: 当然,你可以对其属性进行更多地设置,比如,设置HeaderTemplate(头模版),StartNavigationTemplate(开始...

    ASP.NET2.0MemberShipUser.doc

    membership简介 2.membership在sql server中的设置 3.配置web.config 4.创建用户CreateUserWizard控件 5.用户登录login控件 6.显示当前用户的名称LoginName控件 7.检测用户的身份验证状态的LoginStatus控

    ASP.NET3.5从入门到精通

    12.4 使用Microsoft Expression Web 2 制作页面 12.4.1 创建ASPX 页面 12.4.2 创建CSS 层叠样式表 12.4.3 创建框架集 12.5 小结 第 13 章 ASP.NET 内置对象,应用程序配置和缓存 13.1 ASP.NET 内置对象 13.1.1 ...

    ASP.NET4高级程序设计第4版 带目录PDF 分卷压缩包 part1

    11.3.4 使用数据源控件的缓存 11.4 缓存依赖 11.4.1 文件和缓存项目依赖 11.4.2 聚合依赖 11.4.3 移除项目回调 11.4.4 理解SQL缓存通知 11.4.5 缓存通知的工作方式 11.4.6 启用通知 11.4.7 创建...

    ASP.NET 3.5 开发大全11-15

    12.4 使用Microsoft Expression Web 2制作页面 12.4.1 创建ASPX页面 12.4.2 创建CSS层叠样式表 12.4.3 创建框架集 12.5 小结 第13章 ASP.NET内置对象,应用程序配置和缓存 13.1 ASP.NET内置对象 13.1.1 Request传递...

    ASP.NET 3.5 开发大全

    12.4 使用Microsoft Expression Web 2制作页面 12.4.1 创建ASPX页面 12.4.2 创建CSS层叠样式表 12.4.3 创建框架集 12.5 小结 第13章 ASP.NET内置对象,应用程序配置和缓存 13.1 ASP.NET内置对象 13.1.1 Request传递...

    ASP.NET 3.5 开发大全1-5

    12.4 使用Microsoft Expression Web 2制作页面 12.4.1 创建ASPX页面 12.4.2 创建CSS层叠样式表 12.4.3 创建框架集 12.5 小结 第13章 ASP.NET内置对象,应用程序配置和缓存 13.1 ASP.NET内置对象 13.1.1 Request传递...

    ASP.NET 3.5 开发大全word课件

    12.4 使用Microsoft Expression Web 2制作页面 12.4.1 创建ASPX页面 12.4.2 创建CSS层叠样式表 12.4.3 创建框架集 12.5 小结 第13章 ASP.NET内置对象,应用程序配置和缓存 13.1 ASP.NET内置对象 13.1.1 Request传递...

    ASPNET35开发大全第一章

    12.4 使用Microsoft Expression Web 2制作页面 12.4.1 创建ASPX页面 12.4.2 创建CSS层叠样式表 12.4.3 创建框架集 12.5 小结 第13章 ASP.NET内置对象,应用程序配置和缓存 13.1 ASP.NET内置对象 13.1.1 Request传递...

    ASP.NET4高级程序设计(第4版) 3/3

    11.3.4 使用数据源控件的缓存 376 11.4 缓存依赖 379 11.4.1 文件和缓存项目依赖 379 11.4.2 聚合依赖 380 11.4.3 移除项目回调 381 11.4.4 理解SQL缓存通知 383 11.4.5 缓存通知的工作方式 384 ...

Global site tag (gtag.js) - Google Analytics