我已經定製了asp.net登錄控件,它似乎創建新帳戶正常,但如果我複製已註冊的用戶標識或輸入已使用的電子郵件,錯誤消息不會顯示。這讓我瘋狂。該頁面只刷新而不顯示錯誤。與asp.net創建用戶控件的問題
我已經包含了MSDN網站上的指示,但沒有任何內容。 http://msdn.microsoft.com/en-us/library/ms178342.aspx
<asp:CreateUserWizard ErrorMessageStyle-BorderColor="Azure" ID="CreateUserWizard1" runat="server" ContinueDestinationPageUrl="~/home.aspx">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
<div class="fieldLine">
<asp:Label ID="lblFirstName" runat="server" Text="First Name:" AssociatedControlID="tbxFirstName"></asp:Label>
<asp:Label ID="lblLastName" runat="server" Text="Last Name:" AssociatedControlID="tbxLastName"></asp:Label>
</div>
<div class="fieldLine">
<asp:TextBox ID="tbxFirstName" runat="server"></asp:TextBox>
<asp:TextBox ID="tbxLastName" runat="server"></asp:TextBox>
</div>
<asp:Label ID="lblEmail" runat="server" Text="Email:" AssociatedControlID="Email"></asp:Label>
<asp:TextBox ID="Email" runat="server" CssClass="wideInput"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
CssClass="aspValidator"
Display="Dynamic"
ControlToValidate="Email"
ErrorMessage="Required"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
Display="Dynamic"
CssClass="aspValidator"
ControlToValidate="Email"
SetFocusOnError="true"
ValidationExpression="^(?:[a-zA-Z0-9_'^&/+-])+(?:\.(?:[a-zA-Z0-9_'^&/+-])+)*@(?:(?:\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)|(?:[a-zA-Z0-9-]+\.)+(?:[a-zA-Z]){2,}\.?)$"
ErrorMessage="Email address not valid"></asp:RegularExpressionValidator>
<asp:Label ID="lblEmailConfirm" runat="server" Text="Confirm Email Address:" AssociatedControlID="tbxEmailConfirm"></asp:Label>
<asp:TextBox ID="tbxEmailConfirm" runat="server" CssClass="wideInput"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server"
CssClass="aspValidator"
Display="Dynamic"
ControlToValidate="tbxEmailConfirm"
ErrorMessage="Required"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2"
runat="server"
Display="Dynamic"
CssClass="aspValidator"
ControlToValidate="tbxEmailConfirm"
SetFocusOnError="true"
ValidationExpression="^(?:[a-zA-Z0-9_'^&/+-])+(?:\.(?:[a-zA-Z0-9_'^&/+-])+)*@(?:(?:\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)|(?:[a-zA-Z0-9-]+\.)+(?:[a-zA-Z]){2,}\.?)$"
ErrorMessage="Email address not valid"></asp:RegularExpressionValidator>
<asp:CompareValidator ID="CompareValidator1"
runat="server"
Display="Dynamic"
SetFocusOnError="true"
CssClass="aspValidator"
ControlToCompare="Email"
ControlToValidate="tbxEmailConfirm"
ErrorMessage="Email address' do not match"></asp:CompareValidator>
<asp:Label ID="lblUsername" runat="server" Text="Username:" AssociatedControlID="UserName"></asp:Label>
<asp:TextBox ID="UserName" runat="server" MaxLength="12"></asp:TextBox><br />
<asp:CustomValidator ID="CustomValidatorUserName"
runat="server"
Display="Dynamic"
SetFocusOnError="true"
CssClass="aspValidator"
ValidateEmptyText="true"
ControlToValidate="UserName"
ErrorMessage="Username can be between 6 and 12 characters."
ClientValidationFunction="ValidateLength"
OnServerValidate="ValidateUserName"></asp:CustomValidator>
<div class="fieldLine">
<asp:Label ID="lblPassword" runat="server" Text="Password:" AssociatedControlID="Password"></asp:Label>
<asp:Label ID="lblPasswordConfirm" runat="server" Text="Confirm Password:" AssociatedControlID="ConfirmPassword" CssClass="confirmPassword"></asp:Label>
</div>
<div class="fieldLine">
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox><br />
<asp:CustomValidator ID="CustomValidatorPassword"
runat="server"
Display="Dynamic"
SetFocusOnError="true"
CssClass="aspValidator"
ControlToValidate="Password"
ValidateEmptyText="true"
ErrorMessage="Password can be between 6 and 12 characters"
ClientValidationFunction="ValidateLength"
OnServerValidate="ValidatePassword"></asp:CustomValidator>
<asp:CustomValidator ID="CustomValidatorConfirmPassword"
runat="server"
Display="Dynamic"
SetFocusOnError="true"
CssClass="aspValidator"
ControlToValidate="ConfirmPassword"
ValidateEmptyText="true"
ErrorMessage="Password can be between 6 and 12 characters"
ClientValidationFunction="ValidateLength"
OnServerValidate="ValidatePassword"></asp:CustomValidator>
<asp:CompareValidator ID="CompareValidator2"
runat="server"
Enabled="false"
Display="Dynamic"
SetFocusOnError="true"
CssClass="aspValidator"
ControlToCompare="Password"
ControlToValidate="ConfirmPassword"
ErrorMessage="Passwords do not match"></asp:CompareValidator>
</div>
<asp:Label ID="lblCaptch" runat="server" Text="Captcha:" AssociatedControlID="imgCaptcha"></asp:Label>
<div class="borderBlue" style="width:200px;">
<asp:Image ID="imgCaptcha" runat="server" ImageUrl="~/JpegImage.aspx" /><br />
</div>
<asp:TextBox ID="tbxCaptcha" runat="server" CssClass="captchaText"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="tbxCaptcha"
CssClass="aspValidator"
ID="RequiredFieldValidator3"
runat="server"
ErrorMessage="Required"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" ControlToValidate="tbxCaptcha"
runat="server" OnServerValidate="ValidateCaptcha" ErrorMessage="Captcha incorrect"></asp:CustomValidator>
</ContentTemplate>
<CustomNavigationTemplate>
<div style="float:left;">
<asp:Button ID="CreateUser" runat="server" Text="Register Now!"
CausesValidation="true" CommandName="CreateUser" OnCommand="CreateUserClick" CssClass="registerButton" />
</div>
</CustomNavigationTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
<ContentTemplate>
<table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
<tr>
<td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d; height: 18px;">
Complete</td>
</tr>
<tr>
<td>
Your account has been successfully created.<br />
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="Button1" PostBackUrl="~/home.aspx" runat="server" Text="Button" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
您能鏈接到您引用的MSDN文檔嗎? – 2009-08-15 07:44:15