在asp Multiview中使用验证

时间:2012-08-07 05:54:19

标签: asp.net validation multiview

我正在尝试在包含两个视图的页面中使用验证。第一个视图有效,但不是第二个视图。 Validationsummary错误永远不会显示,它会吞噬我提供给它的任何内容,甚至是非常不正确的数据。所以..我肯定错过了一些东西,或者这个组合是不可能的?我是否需要自己捕获验证以防止不正确的数据,然后我该怎么做? 此致

    <form id="form1" runat="server" defaultfocus="txtCardID">
<div>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
            ValidationGroup="action" ShowMessageBox="True" ShowSummary="False" />
    <asp:Panel ID="pnlCardID" runat="server">
        <asp:MultiView ID="Mview" runat="server">
        <asp:View runat="server" ID="card">
    .......
                 <asp:TextBox ID="txtAmount" runat="server" Columns="6" MaxLength="6" 
                        ValidationGroup="action"></asp:TextBox> 
                    <asp:RequiredFieldValidator ID="rfvSum" runat="server" 
                        ErrorMessage="Error!" Text="*"     ValidationGroup="action" 
                        ControlToValidate="txtAmount" Display="Dynamic" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="rngvSum" runat="server" 
                        ErrorMessage="Error!" Text="*" 
                        ValidationGroup="action" ControlToValidate="txtAmount" Display="Dynamic" 
                        SetFocusOnError="True" MaximumValue="99999" MinimumValue="1" Type="Currency"></asp:RangeValidator>
  .......
              <asp:view runat="server" ID="purchase">
  .......
                      <td><asp:TextBox ID="txtSum" runat="server" Columns="6" MaxLength="6" 
                        ToolTip="Total sum" ValidationGroup="action" /> 
                   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ErrorMessage="Another Error!" Text="*" ValidationGroup="action" 
                        ControlToValidate="txtSum" Display="Dynamic" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" 
                        ErrorMessage="Error again!" Text="*" 
                        ValidationGroup="action" ControlToValidate="txtSum" Display="Dynamic" 
                        SetFocusOnError="True" MaximumValue="99999" MinimumValue="1" Type="Currency"></asp:RangeValidator>
                        </td>

0 个答案:

没有答案