我有一個文本框和一個GridView中的按鈕。當按鈕被點擊時,文本框有驗證。然而,當再次點擊按鈕時,驗證事件永遠不會被觸發。CustomValidation沒有發射第二次點擊
<asp:GridView ID="ChapterGridView"
EnableSortingAndPagingCallbacks="false"
AllowSorting="false"
AllowPaging="false"
runat="server"
AutoGenerateColumns="False"
CellPadding="2"
ForeColor="#333333"
GridLines="None"
Width="780px"
OnRowCommand="ChapterGridView_OnRowCommand"
ShowFooter="False"
AutoGenerateDeleteButton="true"
AutoGenerateEditButton="true"
onrowediting="ChapterGridView_RowEditing"
onrowdeleting="ChapterGridView_RowDeleting"
onrowcancelingedit="ChapterGridView_RowCancelingEdit"
onrowupdating="ChapterGridView_RowUpdating"
onrowupdated="ChapterGridView_RowUpdated"
DataKeyNames="ChapterId"
ValidationGroup="ChapterValidation"
Visible="true">
<FooterStyle BackColor="#eeeeee" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="*End Page" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate><%# Eval("EndPage")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="EndPage" runat="Server" Text='<%# Eval("EndPage") %>'></asp:TextBox>
<asp:CustomValidator ID="TotalPagesValidator" ValidationGroup="ChapterValidation" OnServerValidate="TotalPages_ServerValidate" EnableClientScript="false" ErrorMessage="Number of pages in chapter are greater than number of pages in entire publication." Display="None" ControlToValidate="EndPage" runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="EndPage" runat="Server"></asp:TextBox>
<asp:CustomValidator ID="TotalPagesValidator2" ValidationGroup="ChapterValidation" OnServerValidate="TotalPages_ServerValidate" EnableClientScript="false" ErrorMessage="Number of pages in chapter are greater than number of pages in entire publication." Display="None" ControlToValidate="EndPage" runat="server" />
<asp:Button ID="btnInsert" runat="Server" Text="Insert" CommandName="Insert" UseSubmitBehavior="false" ValidationGroup="ChapterValidation" /></span>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
對編輯的驗證與預期相同。但不適用於插入按鈕。有什麼建議麼?
是的,有回傳。驗證不被調用。 – dcinadr
是的,我嘗試改變驗證組,但它沒有奏效。 – dcinadr
我注意到你有顯示=「無」驗證控件。你使用ValidatorCallout嗎?如果不是,你不應該設置顯示=「動態」或「靜態」。 – TrekStir