我想在对话框中显示验证错误。
我有以下jQuery代码:
<script type="text/javascript">
function WebForm_OnSubmit() {
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
$("#errorDisplay").dialog({
title: "Validation Error",
modal: true,
resizable: false,
width: 250,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
return false;
}
return true;
}
</script>
我有以下GridView
片段,其中包含要进行验证的控件:
<asp:GridView ID="gvBins" runat="server" AllowPaging="True" ShowFooter="true"
PageSize="10" AllowSorting="True" AutoGenerateColumns="False"
ShowHeaderWhenEmpty="True" CssClass="DataWebControlStyle"
EnableTheming="False" onsorting="gvBins_Sorting"
onpageindexchanging="gvBins_PageIndexChanging"
onpageindexchanged="gvBins_PageIndexChanged"
onselectedindexchanged="gvBins_SelectedIndexChanged"
onsorted="gvBins_Sorted" onrowcancelingedit="gvBins_RowCancelingEdit"
onrowediting="gvBins_RowEditing" onrowupdating="gvBins_RowUpdating"
onrowdatabound="gvBins_RowDataBound">
<AlternatingRowStyle CssClass="even" />
<RowStyle CssClass="odd" />
<HeaderStyle CssClass="ui-state-default" Height="40px" />
<PagerStyle CssClass="pager-row" />
<FooterStyle CssClass="ui-state-default" Height="40px" />
<Columns>
<asp:TemplateField HeaderText="Bin" HeaderStyle-Width="80px" SortExpression="Bin" HeaderStyle-CssClass="binGridHeader" FooterStyle-CssClass="binGridFooter">
<ItemTemplate>
<asp:Label ID="lblBin" runat="server" Text='<%# Bind("BinNumber") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblBinEdit" runat="server" Text='<%# Bind("BinNumber") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAddBin" runat="server" Width="70%" MaxLength="6"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Bin is missing" ControlToValidate="txtAddBin" ForeColor="Red" ValidationGroup="vgBinAdd">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Invalid Bin Entered" ControlToValidate="txtAddBin" ForeColor="Red" ValidationGroup="vgBinAdd" ValidationExpression="^[0-9]{6}$"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Currency" HeaderStyle-Width="80px" SortExpression="Currency" HeaderStyle-CssClass="binGridHeader" FooterStyle-CssClass="binGridFooter">
<ItemTemplate>
<asp:Label ID="lblCurrency" runat="server" Text='<%# Bind("Currency") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlEditCurrency" runat="server" AppendDataBoundItems="true" OnDataBinding="ddlCurrencyCodes_OnDataBinding" >
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvtxtBinEditCurrency" runat="server" ErrorMessage="Need to Select Currency" ControlToValidate="ddlEditCurrency" ForeColor="Red" ValidationGroup="vgBinUpdate">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlAddCurrency" runat="server" AppendDataBoundItems="true" OnDataBinding="ddlCurrencyCodes_OnDataBinding" >
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Need to Select Currency" ControlToValidate="ddlAddCurrency" ForeColor="Red" ValidationGroup="vgBinAdd">*</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
</asp:GridView>
我有以下验证摘要控件:
<div id="errorDisplay" style="display: none">
<asp:ValidationSummary runat="server" id="validationSummary"></asp:ValidationSummary>
</div>
当验证失败时,我的对话框与*
一起显示所需的正则表达式验证器。
但是,Error Message
文本不会显示在对话框中。
我不确定我做错了什么。