MembershipCreateStatus iStatus;
Membership.CreateUser(username, password, email, question, answer, true, out iStatus);
ErrirMsgText.Visible = true;
switch (iStatus)
{
case MembershipCreateStatus.Success:
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(username, false);
}
else
{
FormsAuthentication.SetAuthCookie(username,false);
Response.Redirect("~/default.aspx");
}
ErrirMsgText.Text = "新用户创建成功!";
break;
case MembershipCreateStatus.InvalidUserName:
ErrirMsgText.Text = "无效的用户名。";
break;
case MembershipCreateStatus.DuplicateEmail:
ErrirMsgText.Text = "重复的电子邮件地址。";
break;
case MembershipCreateStatus.InvalidQuestion:
ErrirMsgText.Text = "无效的密码提示问题。";
break;
case MembershipCreateStatus.DuplicateUserName:
ErrirMsgText.Text = "该用户名已注册,请更换用户名。";
break;
case MembershipCreateStatus.InvalidAnswer:
ErrirMsgText.Text = "无效的密码答案。";
break;
case MembershipCreateStatus.InvalidEmail:
ErrirMsgText.Text = "无效的电子邮件地址。";
break;
case MembershipCreateStatus.InvalidPassword:
ErrirMsgText.Text = "密码须为7位,并且有1个特殊符号。";
break;
default:
ErrirMsgText.Text = "出现未知错误!请联系网站管理员。";
break;
}
ErrirMsgText.Visible = true;
switch (iStatus)
{
case MembershipCreateStatus.Success:
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(username, false);
}
else
{
FormsAuthentication.SetAuthCookie(username,false);
Response.Redirect("~/default.aspx");
}
ErrirMsgText.Text = "新用户创建成功!";
break;
case MembershipCreateStatus.InvalidUserName:
ErrirMsgText.Text = "无效的用户名。";
break;
case MembershipCreateStatus.DuplicateEmail:
ErrirMsgText.Text = "重复的电子邮件地址。";
break;
case MembershipCreateStatus.InvalidQuestion:
ErrirMsgText.Text = "无效的密码提示问题。";
break;
case MembershipCreateStatus.DuplicateUserName:
ErrirMsgText.Text = "该用户名已注册,请更换用户名。";
break;
case MembershipCreateStatus.InvalidAnswer:
ErrirMsgText.Text = "无效的密码答案。";
break;
case MembershipCreateStatus.InvalidEmail:
ErrirMsgText.Text = "无效的电子邮件地址。";
break;
case MembershipCreateStatus.InvalidPassword:
ErrirMsgText.Text = "密码须为7位,并且有1个特殊符号。";
break;
default:
ErrirMsgText.Text = "出现未知错误!请联系网站管理员。";
break;
}
MembershipCreateStatus iStatus;
这个东西返回你注册用户时的结果
这个东西返回你注册用户时的结果
下面的swicth代码块则根据这个结果给出相应的提示