0
我有一些驗證控件和驗證摘要。 用戶離開文本框進行驗證後,客戶端驗證顯示出來。 服務器端驗證顯示從未啓動。 驗證摘要顯示永不起作用。ValidationSummary不顯示
我做錯了什麼?
<div class="designPhotoMiddleText" id="MiddleReg" >
<asp:Panel DefaultButton="linkRegister" runat="server" ID="panRegister" >
Jetzt kostenlos registrieren:<br />
<br />
<table>
<tr>
<td style="width: 120px;">
Username:
</td>
<td>
<asp:TextBox ID="txtRegisterUsername" Width="150px" runat="server"></asp:TextBox>
<asp:CustomValidator ValidationGroup="Register" ID="valUsername" ControlToValidate="txtRegisterUsername"
OnServerValidate="IsUsernameFree" CssClass="validator"
runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>
</td>
</tr>
<tr>
<td>
Passwort:
</td>
<td>
<asp:TextBox ID="txtRegisterPW1" Width="150px" TextMode="Password" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ValidationGroup="Register" CssClass="validator" ControlToValidate="txtRegisterPW1" ID="valPasswordLenght" runat="server" ErrorMessage="Das Passwort muss mindestens 6 Zeichen haben."></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
Passwort erneut:
</td>
<td>
<asp:TextBox ID="txtRegisterPW2" Width="150px" TextMode="Password" runat="server"></asp:TextBox>
<asp:CompareValidator CssClass="validator" ValidationGroup="Register"
ID="valPW" ControlToCompare="txtRegisterPW2" ControlToValidate="txtRegisterPW1" runat="server" ErrorMessage="Die eingegebenen Passwörter stimmen nicht überein."></asp:CompareValidator>
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<asp:TextBox ID="txtRegisterEmail" Width="150px" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ValidationGroup="Register" CssClass="validator" ForeColor="black"
ControlToValidate="txtRegisterEmail" ID="valMail" runat="server"
ValidationExpression=".*@.*\.(com|net|org|edu|mil|at?|de?|ch?|uk?)$"
ErrorMessage="Bitte geben Sie eine gültige EMail-Adresse ein."
Display="Dynamic"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:CheckBox ID="chkRegsiterAGBs" runat="server" />
<asp:HyperLink ID="linkAGB" Target="_blank" NavigateUrl="~/AGBs.aspx" runat="server">AGBs</asp:HyperLink> gelesen
<asp:CustomValidator ValidationGroup="Register" ID="valAGB"
OnServerValidate="IsAGBChecked" CssClass="validator"
runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton CausesValidation="true" ID="linkRegister" CssClass="linkWhite" runat="server"
onclick="linkRegister_Click">Jetzt Registrieren</asp:LinkButton>
<asp:ValidationSummary ValidationGroup="Register" ID="sumRegister" runat="server"
HeaderText="Fehler:"
ShowSummary="true" DisplayMode="BulletList" />
</td>
</tr>
</table>
</asp:Panel>
</div>
public void IsUsernameFree(object source, ServerValidateEventArgs value)
{
string username = value.Value;
DAL.User user = DAL.UserHandling.GetUserByName(username);
value.IsValid = (user == null);
}
public void IsAGBChecked(object source, ServerValidateEventArgs value)
{
value.IsValid = (chkRegsiterAGBs.Checked);
}
是的,我這樣做。在linkRegister_Click上。 – Kovu 2010-12-12 10:49:27
我*想*我發現你的問題 - 請參閱我上面的編輯。 – 5arx 2010-12-12 11:14:16
完美,完美,謝謝。 – Kovu 2010-12-12 11:57:11