ValidationSummary不显示错误 [英] ValidationSummary doesn't show Errors

查看:89
本文介绍了ValidationSummary不显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的gridview出现问题,不再显示ValidationSummary错误.会显示ValidationSummary的标题文本,以及在ExpressionValidation触发时设置的*.

I have a problem with my gridview which won't show the ValidationSummary-errors anymore. The Headertext of the ValidationSummary does show up as well as the * which I set to appear whenever the ExpressionValidation fires.

我很确定它以前曾经起作用,但是我不知道为什么它不再起作用了.起初,我认为它可能与页面上的其他GridView有关,因为我在不同的TabPanels中拥有5个不同的GridView,但是我已经为每个GridView创建了一个验证组.

I'm quite sure it worked before, but I don't know why it doesn't anymore. At first I thought it might have something to do with the other GridViews on the page as I have like 5 different GridView in different TabPanels, but I already made one validationgroup per GridView.

标记:

<asp:UpdatePanel runat="server" UpdateMode="Always">
    <ContentTemplate>
       <asp:GridView ID="gvBBG" runat="server" AutoGenerateColumns="false" DataKeyNames="ID" SkinID="gvWithoutWidth">
         <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                   <asp:ImageButton runat="server" ImageUrl="~/Images/GridView/gv_edit.png" CommandName="Edit"/>
                </ItemTemplate>
                <EditItemTemplate>
                   <asp:ImageButton runat="server" ImageUrl="~/Images/GridView/gv_cancel.png" CommandName="Cancel" CausesValidation="false"/>
                   <asp:ImageButton Id="ibUpdate" runat="server" ImageUrl="~/Images/GridView/gv_update.png" CommandName="Update"  CausesValidation="true"
                        ValidationGroup="UpdateBBG" Enabled="true" OnClientClick="return confirm('Datensatz einspielen/aktualisieren?')"/>
                </EditItemTemplate>
           </asp:TemplateField>
           <asp:TemplateField HeaderText="KV West" HeaderStyle-HorizontalAlign="Left">
               <EditItemTemplate>
                    <asp:TextBox ID="tbKVWest" runat="server" Text='<%# Bind("KVWestFormatted") %>' ValidationGroup="UpdateBBG" Width="50px" Height="15px"></asp:TextBox>
                     <asp:RequiredFieldValidator ID="rfvKVWest" ValidationGroup="UpdateBBG" runat="server"
                           ControlToValidate="tbKVWest" ErrorMessage="Bitte KVWest als Summe angeben"
                           SetFocusOnError="true">*</asp:RequiredFieldValidator> 
                      <asp:RegularExpressionValidator ID="revKVWest" ValidationGroup="UpdateBBG" runat="server"
                           ValidationExpression="^[0-9]{1,9}((\,)[0-9]{1,2})?$" ControlToValidate="tbKVWest" SetFocusOnError="true">*</asp:RegularExpressionValidator>
              </EditItemTemplate>
              <ItemTemplate>
                  <%# Eval("KVWestFormatted")%>
              </ItemTemplate>
        </asp:TemplateField>
....
      </Columns>
          <EmptyDataTemplate>Keine Daten vorhanden</EmptyDataTemplate>
  </asp:GridView>
      <p>
            <asp:ValidationSummary ID="vsUpdate3" runat="server" ShowMessageBox="true" ShowSummary="true" ValidationGroup="UpdateBBG" Font-Bold="true" ForeColor="Red" 
                 EnableClientScript="true" Enabled="true" HeaderText="Validierung..." />
      </p>

如果你们能在这里帮助我,那会很好.我不太清楚问题是什么..也许是UpdatePanel吗?也许我犯了一些愚蠢的错误..?我很笨.

Would be nice if you guys could help me out here. Im not quite sure what the problem is .. maybe it's the UpdatePanel? Maybe I made some dumb mistake ..? I'm rather clueless.

推荐答案

发现了问题..我必须同时为RequiredFieldValidator和RegularExpressionValidator设置错误消息.;)您不需要在文本框btw内添加验证组.

Found The problem .. I have to set the errormessage for both RequiredFieldValidator and RegularExpressionValidator. ;) You don't need the validationgroup inside of the textbox btw.

这篇关于ValidationSummary不显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆