提交按钮不适用于updatepanel内的验证器

时间:2012-06-12 09:10:27

标签: asp.net updatepanel validation requiredfieldvalidator

<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Always">
    <ContentTemplate>
        <asp:ListView ID="EditModeListView" runat="server" DataSourceID="DataSourceWrite">
            <itemtemplate>
                <tr class="cat" onclick="return ApplyTRToggle(this);">
                    <td colspan="5"><img src="/_layouts/images/COLLAPSE.GIF" class="toggle-img"/>  <%# Eval("Cat.CategoryName")%></td>
                </tr>
                <asp:ListView ID="SubListView" runat="server" DataSource='<%# Eval("Blocks") %>'  >
                    <ItemTemplate>
                        <tr class="sec" onclick="return ApplyTRToggle(this);">
                            <td></td>
                            <td><img src="/images/COLLAPSE.GIF" /><%# Eval("Block.CategoryName")%> </td>
                            <td></td>
                            <td><%# Eval("StringFormat") != null ? String.Format(Eval("StringFormat").ToString(), Eval("BlockSum")):Eval("BlockSum") %></td>
                            <td>
                                <asp:ListView ID="SuberListView" runat="server" DataSource='<%# Eval("Crits") %>'  >
                                    <ItemTemplate>
                                        <tr>
                                            <asp:HiddenField ID="Identifier" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "ValueID")%>' />
                                            <td></td>
                                            <td><%# Eval("Crit.CategoryName")%></td>
                                            <td><%# Eval("CritUnit")%></td>
                                            <td>
                                                <asp:HiddenField runat="server" ID="IsDecimalController" Value='<%# DataBinder.Eval(Container.DataItem, "IsDecimal")%>' />
                                                <asp:TextBox runat="server" ID="ValueControl" Text='<%# DataBinder.Eval(Container.DataItem, "CritSum")%>' MaxLength="12"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="ErrorMSG" ValidationGroup="NumbersValidation" ControlToValidate="ValueControl" Display="Dynamic"></asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression='<%# Const.FLOAT_DIGITALS%>' ValidationGroup="NumbersValidation" ErrorMessage="ErrorMSGG" ControlToValidate="ValueControl" Display="Dynamic" />
                                            </td>
                                            <td><%# DataBinder.Eval(Container.DataItem ,"Crit.Comment")%></td>
                                        </tr>
                                    </ItemTemplate>
                                    <LayoutTemplate>
                                        <div ID="itemPlaceholder" runat="server"></div>
                                    </LayoutTemplate>
                                </asp:ListView> 
                            </td>
                        </tr>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <tr ID="itemPlaceholder" runat="server"></tr>
                    </LayoutTemplate>
                </asp:ListView>
            </itemtemplate>
            <layouttemplate>
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <div runat="server" ID="itemPlaceholder">
                        </div>
                    </table>
                <div class="indicators-toolbar">
                    <asp:Button runat="server" ID="saveButton" Text="Save" ValidationGroup="NumbersValidation" CausesValidation="true" onclick="saveButton_Click"/>
                    <asp:Button runat="server" ID="cancelButton" Text="Cancel" CssClass="ms-ButtonHeightWidth" CausesValidation="false" onclick="cancelButton_Click"/>
                </div>
            </layouttemplate>
        </asp:ListView>
    </ContentTemplate>
</asp:UpdatePanel>

我的usercontrol中的内容。问题是当键入无有效文本或在<asp:TextBox runat="server" ID="ValueControl" Text='<%# DataBinder.Eval(Container.DataItem, "CritSum")%>' MaxLength="12"></asp:TextBox> fires requiredfield validator中显示为空时显示错误文本..然后按提交按钮,没有任何反应,但是在文本框中键入正确的文本后没有验证器触发提交按钮不工作。如何解决问题

1 个答案:

答案 0 :(得分:0)

点击按钮时触发ajax中的触发器..... 它可能会对你有所帮助

   </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="imgbtnSubmit" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>