惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
博客园 - Franky
MyScale Blog
MyScale Blog
L
LangChain Blog
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
量子位
A
About on SuperTechFans
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
V
Visual Studio Blog
Vercel News
Vercel News
B
Blog
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
U
Unit 42

博客园 - 麦子

高级语言程序设计实验大纲 面向对象程序设计实验大纲 参考后原创:ASP.NET2.0个性化注册登录系统.rar 关于《ASP.NET2.0网站开发实例教程》中1.1.4 Default.aspx页面的实现的说明 转贴:关于membership实用性讨论 asp.net2.0 站点登录,导航与权限管理,角色及用户信息存储于SQL2000的的方法。 装了VS2005再装IIS的小问题 《 C 语言程序设计》教材中涉及到的常用词汇荟萃 动态网页设计(全)部课件和进度表, C语言程序课件和进度表 03级函授毕业证领取通知 转贴:《ASP.NET2.0开发指南》样单,第1章 ASP.NET 2.0概述 正式入火(10月1日) 电子商务基础课件(10.25更新) 搬家(53天) 准备搬家,乱 装修相片(第50天拍,全部,25号更新) 装修(48天,装修全部价格清单,装好窗帘,晒书) 装修(46天,家具基本上弄好啦) 装修(43天,安装新家具啦)
ASP.NET2.0 自定义CreateUserWizard
麦子 · 2007-05-22 · via 博客园 - 麦子

MSND原文如下:

下面的代码示例使用 CreatedUser 事件将用户姓名存储在个性化属性中。该代码示例需要 Web.config 文件中的下列项。

<configuration>

<system.web>

<profile>

<properties>

<add name="lastName" />

<add name="firstName" />

</properties>

</profile>

</system.web>

</configuration>

 
                
C#  复制代码
<%@ page language="C#"%>
            <script runat="server">
            void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
            {
            Profile.SetPropertyValue("UserName",firstName.Text + " " + lastName.Text);
            }
            </script>
            <html>
            <head runat="server">
            <title>
            CreateUserWizard.CreatedUser sample</title>
            </head>
            <body>
            <form id="form1" runat="server">
            <div>
            <asp:createuserwizard id="CreateUserWizard1" 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>
            


上面加入了一个自定义的wizardstep ,在界面上,可以如下操作:在CreateUserWizard控件上右击,在弹出的菜单上选择“ADD/REMOVE wizardstep”,在出出的界面上单击ADD就可以增加一个wizardstep,用上下箭头把新建的步骤置于中间。

发现按此做,会有些错误;

改正如下:
  1.配置文件中<add name="lastName" /> <add name="firstName" /> 与后面的Profile.SetPropertyValue("UserName",firstName.Text + " " + lastName.Text);  不一致。改正方法1是前者改为.<add name="UserName" />,或者后者改成:Profile.SetPropertyValue("firstName",firstName.Text);Profile.SetPropertyValue("lastName", lastName.Text); 
2.Profile.SetPropertyValue("UserName",firstName.Text + " " + lastName.Text);  后面添加语句Profile.Save(),否则不会保存。
3.配置文件中应允许匿名访问Profile:
<system.web>
      <anonymousIdentification        enabled="true"     />

    <profile >
      <properties >
       <add name="lastName" allowAnonymous="true"/>
        <add name="firstName" allowAnonymous="true"/>
      </properties>
    </profile></system.web>
4.代码应编写在完成注册的按钮下面:
       protected void CreateUserWizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        Profile.SetPropertyValue("firstName", firstName.Text);
        Profile.SetPropertyValue("lastName", lastName.Text);
        Profile.Save();
    }