net2.0的用户角色管理和权限控制功能机器强大,我们甚至可以不写一句代码就能够完成注册登陆授权等工作.如果要自定义注册控件又要使用net2.0字带的功能丰富的用户和角色管理功能你必须要写web.config.
如下:
<system.web>
    <membership defaultProvider="MyAspNetSqlProvider" userIsOnlineTimeWindow="20">
      <providers>
        <remove name="AspNetSqlProvider" />
        <add name="MyAspNetSqlProvider"
             type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="LocalSqlServer"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             applicationName="/"
             requiresUniqueEmail="false"
             passwordFormat="Hashed"
             minRequiredPasswordLength="6"
             minRequiredNonalphanumericCharacters="0"
             passwordStrengthRegularExpression="" />
      </providers>
    </membership>

requiresQuestionAndAnswer="false"         //等于false就是不需要输入密码问题和答案.

minRequiredPasswordLength="6" 
minRequiredNonalphanumericCharacters="0" 
passwordStrengthRegularExpression="" 
这三句是控件密码强度和长度

注册代码:
protected void Button1_Click(object sender, EventArgs e)
    {
        Membership.CreateUser("pwqzc","123456"," [email protected]");
    }


   TrackBack: http://pwqzc.cnblogs.com/archive/2005/11/25/284225.html