也許這個問題聽起來很愚蠢。 以上聲明中提供者是誰? 提供所需錯誤的程序員,創建會員資格的用戶還是其他人? 具體來說,我想顯示錯誤,當用戶鍵入超過最大長度字符如下: ps。找到在geterrormessage方法*行...asp.net:specify錯誤MembershipCreateStatus.ProviderError使用c#
UsernameTextbox.MaxLength = 15;
if (UsernameTextbox.Text.Length > UsernameTextbox.MaxLength)
{
status = MembershipCreateStatus.ProviderError;
Msg.Text = GetErrorMessage(status);
}
public string GetErrorMessage(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
return "Username already exists. Please enter a different user name.";
case MembershipCreateStatus.DuplicateEmail:
return "A username for that e-mail address already exists. Please enter a different e-mail address.";
case MembershipCreateStatus.InvalidPassword:
return "The password provided is invalid. Please enter a valid password value.";
case MembershipCreateStatus.InvalidEmail:
return "The e-mail address provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidAnswer:
return "The password retrieval answer provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidQuestion:
return "The password retrieval question provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidUserName:
return "The user name provided is invalid. Please check the value and try again.";
//****** STAR LINE:i want to show the following message but i don't know if the-->
//-->the provider error method can let me do this
case MembershipCreateStatus.ProviderError:
return "field outreached the maximum length of characters which is:";
case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
請提供一些代碼示例 – Jon 2012-03-30 19:23:21