1

我可以自定义 ASP.NET DB 成员资格提供程序吗?

在我的 ASP.NET 数据库中,我在 Membership 表中添加了两列:Age 和 Address。

在 Register.aspx 页面中有内置字段,例如用户名、电子邮件、密码、确认密码。

我想添加年龄和地址,当用户单击创建用户按钮时,年龄和地址中输入的数据将存储在 ASP.NET DB 中。

4

1 回答 1

0

RegistrationForm如果您想在页面中添加新字段,则必须以编程方式创建自己的字段。

textboxes在您的设计视图中拖动,并在文件后面的代码中写下这个,

protected void CreateUser_Button_Click(object sender, EventArgs e)
    {
        MembershipCreateStatus result;
        try
        {
            if (Page.IsValid)
            {
                Membership.CreateUser(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, true, out result);

                switch (result)
                {
                    case MembershipCreateStatus.DuplicateEmail:
                        Response.Write("Email ID is already exist");
                        break;
                    case MembershipCreateStatus.DuplicateProviderUserKey:
                        break;
                    case MembershipCreateStatus.DuplicateUserName:
                        Response.Write("UserName is already Exists !");
                        break;
                    case MembershipCreateStatus.InvalidAnswer:
                        break;
                    case MembershipCreateStatus.InvalidEmail:
                        Response.Write("Not a Valid Email ID");
                        break;
                    case MembershipCreateStatus.InvalidPassword:
                        Response.Write("Atleast 6 Charcters are required for Password");
                        break;
                    case MembershipCreateStatus.InvalidProviderUserKey:
                        break;
                    case MembershipCreateStatus.InvalidQuestion:
                        break;
                    case MembershipCreateStatus.InvalidUserName:
                        break;
                    case MembershipCreateStatus.ProviderError:
                        Response.Write("Fail to Register ");
                        break;
                    case MembershipCreateStatus.Success:
                        Response.Write("Successfulley Registered");
                        break;
                    case MembershipCreateStatus.UserRejected:
                        Response.Write("Fail to Register, ");
                        break;
                    default:
                        break;
                }
            }
        }
        catch (Exception err)
        {
            Response.Write(err.Message);
        }
    }

并告诉我它是否适合你...

于 2012-05-05T06:39:59.587 回答