當我點擊「LookupButton」時,服務器點擊事件沒有被觸發。奇怪的部分是這個代碼在我們的Dev服務器上工作,但不是QA。如果我從查找按鈕ValidationGroup屬性中刪除「LookupValidationGroup」,頁面會回發,但我的驗證器不起作用。我可以明確地在服務器端進行驗證,但不認爲我需要。按鈕上的回發沒有被觸發使用驗證器時點擊
沒有顯示錯誤。我還使用aspnet_regiis -i命令重新安裝了.net 3.5。
感謝任何幫助或提供建議......
<table>
<tr>
<td><label for="CRCIDTextBox">CRC ID</label> </td>
<td><asp:TextBox ID="CRCIDTextBox" runat="server" MaxLength="50" CssClass="RegisterInputTextBox" Columns="10"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="CRCIDRequired" runat="server" ControlToValidate="CRCIDTextBox" EnableClientScript="true"
Display="Dynamic" ErrorMessage="CRC ID is required." ToolTip="CRC ID is required." ValidationGroup="LookupValidationGroup"
CssClass="ValidationError" SetFocusOnError="true">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="CRCIDRegularExpressionValidator" runat="server" ControlToValidate="CRCIDTextBox" EnableClientScript="true"
Display="Dynamic" ErrorMessage="CRC ID format is invalid. Please enter only numbers." ValidationExpression="^\d+$" ValidationGroup="LookupValidationGroup"
CssClass="ValidationError" SetFocusOnError="true">
</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td><label for="ZipTextBox">Zip Code</label></td>
<td><asp:TextBox ID="ZipTextBox" runat="server" MaxLength="50" CssClass="RegisterInputTextBox" Columns="10"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="ZipRequired" runat="server" ControlToValidate="ZipTextBox" EnableClientScript="true"
Display="Dynamic" ErrorMessage="Zip Code is required." ToolTip="Zip Code is required." ValidationGroup="LookupValidationGroup"
CssClass="ValidationError" SetFocusOnError="true">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td> </td>
<td><asp:Button ID="LookupButton" runat="server" Text="Lookup" OnClick="LookupButton_OnClick" ValidationGroup="LookupValidationGroup" UseSubmitBehavior="true" /></td>
<td><asp:LinkButton ID="NoSiteIDLinkButton" runat="server" OnClick="NoSiteIDLinkButton_OnClick" CausesValidation="false">Do not have a CRC ID?</asp:LinkButton></td>
</tr>
剛剛複製你的代碼到一個新的網站,它驗證了預期,並且打回傳方法,如果驗證成功。還有什麼可以幫助嗎? – 2011-03-22 08:47:28
這就是奇怪的部分,相同的代碼在不同的服務器上工作。 – obautista 2011-03-22 13:52:25
您是否在其他瀏覽器中嘗試過?它在Chrome,Firefox,IE中工作嗎?瀏覽您的QA服務器時,任何JavaScript都能成功運行嗎? – 2011-03-22 14:47:18