CausesValidation="false"不起作用

本文关键字:quot 不起作用 false CausesValidation | 更新日期: 2023-09-27 18:02:51

我将CausesValidation="false"设置为取消按钮,但是当我单击取消按钮时,exception(arrow)在页面加载后显示了几分之一秒。我尝试了许多方法通过添加组名验证器和EnableClientScript property=false验证器禁用,但这些不能帮助我解决问题。甚至我检查了许多线程,但没有人给出解决方案。如果有人遇到这个问题,请帮助我。

  <form id="form1" runat="server" >
  <div class="AdminContent">
        <asp:Label ID="Label1" runat="server"  
      CssClass="BreadcrumbActiveBig" Text="Group Membership" />
        <asp:ScriptManager ID="ScriptManager1" runat="server"> 
     </asp:ScriptManager>
        <br /><br />
        <asp:HiddenField ID="HiddenFieldProfile" runat="server" 
          />              
        <asp:FormView DefaultMode="Edit" ID="FormView1" runat="server" 
   DataSourceID="PermGroupObjectDataSource1" OnPreRender="FormView1_PreRender">
            <EditItemTemplate>
                <table>
                    <tr>
                        <td align="left" colspan="3">
                            <asp:Button ID="btnSave" 
                  runat="server" OnClick="btnSave_Click" Text="Save" Width="67px" 
        CssClass="ButtonS1"/>
    <asp:Button ID="btnCancel"  runat="server" OnClick="btnCancel_Click" 
      Text="Cancel" CssClass="ButtonS1" CausesValidation="false"  />
                        </td>
                    </tr>
                    <tr>
                        <td><asp:Label ID="lblGrpName" 
       runat="server" Text="Group Name:" Width="138px"/></td>
                        <td><asp:TextBox ID="GroupNameTextBox" 
       MaxLength="50" runat="server" Text='<%# Bind("GroupName") %>' Width="337px"
      ReadOnly="false" />
                            <asp:RequiredFieldValidator ID="rqrgFldVldtr_GroupName" 
      ControlToValidate="GroupNameTextBox" Display="Dynamic" ErrorMessage="&lt;"
                            meta:resourcekey="RequiredFieldValidator1Resource2" 
     runat="server"  ></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td><asp:Label ID="lblGrpDescr" 
    runat="server" Text="Group Description:" Width="138px"/></td>
                        <td><asp:TextBox ID="GroupDescrTextBox" 
   MaxLength="255" runat="server" Text='<%# Bind("GroupDescr") %>' Width="337px" 
    ReadOnly="false" /></td>
                    </tr>
                    <tr>
                        <asp:Panel ID="managedByPanel" runat="server" 
      Visible="false">
                            <td><asp:Label ID="lblManagedByDescr" 
       runat="server" Text="Managed by:" Width="138px"/></td>
                            <td>
                                <asp:DropDownList 
     ID="managedByDropDownList" runat="server">
                                    <asp:ListItem Value="0" 
       Text="Admin" />
                                    <asp:ListItem Value="1" Text="AP Clerk admin &amp; Admin" />
                                    <asp:ListItem Value="2" Text="POC admin &amp; Admin" />
                                </asp:DropDownList>
                            </td>
                        </asp:Panel>
                    </tr>
                    <tr>
                    <asp:Panel ID="lblFilterPanel" runat="server" Visible="false">
                            <td>
                                <asp:Label ID="LabelFilter" runat="server" Text="Exclude From Document Filter" Width="150px"/>
                            </td>
                            <td>
                                <asp:CheckBox ID="chbExcludefromDocFilter" runat="server" 
                                    Checked='<%# Bind("ExcludeFromUserFilter") %>' />
                            </td>
                            </asp:Panel>
                    </tr>
                    <tr>
                        <td valign="top">
                            <asp:Label ID="lblMembers" runat="server" Text="Members:" Width="80px"/>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <div>
                                        <asp:ListBox ID="lbxMembers" runat="server" style="overflow:auto; width:500px; height:150px;" DataSourceID="MembersObjectDataSource1" DataTextField='ListName' DataValueField="UName" SelectionMode="Multiple" /><br />
                                        <asp:ObjectDataSource ID="MembersObjectDataSource1" runat="server" DataObjectTypeName="System.Collections.Generic.List`1[[Accenture.CSTPrague.eAPI.GroupMember, eAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" SelectMethod="FetchGroupMembers" TypeName="Accenture.CSTPrague.eAPI.WebDB_Perm" UpdateMethod="StoreGroupMembers">
                                            <SelectParameters>
                                                <asp:SessionParameter Name="o" SessionField="oPermGroup" Type="Object" />
                                            </SelectParameters>
                                        </asp:ObjectDataSource>
                                    </div>
                                    <asp:Button ID="btnDeleteSelected" runat="server" OnClick="btnDeleteSelected_Click" Text="Delete Selected" Width="106px" CssClass="ButtonS1" Style="margin: 4px 0px 8px 2px;" />
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="btnDeleteSelected" EventName="Click" />
                                </Triggers>
                             </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblUserName" runat="server" Text="User name:" Width="141px"/>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <ContentTemplate>
                                <asp:Panel ID="panel1" runat="server" DefaultButton="btnAdd">
                                    <table>
                                        <tr>
                                            <td valign="top">
                                                <accenture:lookupcontrol ID="UserLookup" runat="server"
                                                    LookupCommand="usr"
                                                    MaxLength="100"
                                                    ValidationGroup="addUser"
                                                    DisableValidation="true"
                                                    />
                                            </td>
                                            <td>
                                                <asp:CustomValidator ID="cuvUserName" runat="server" ValidationGroup="addUser" 
                                                Display="Dynamic" ErrorMessage="<" EnableClientScript="false" OnServerValidate="cuvUserName_ServerValidate"
                                                ControlToValidate="UserLookup" ValidateEmptyText="true" />
                                            </td>
                                            <td valign="top">
                                                <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="Add User" ValidationGroup="addUser" CausesValidation="true" CssClass="ButtonS1" Style="margin: 2px 0px 8px 2px;"/>
                                            </td>
                                        </tr>
                                    </table>  
                                 </asp:Panel> 
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
                                </Triggers>
                             </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr style="vertical-align:top">
                        <asp:Panel ID="queryConditionPanel" runat="server" Visible="false">
                            <td><asp:Label ID="lblQueryCondition" runat="server" Text="Query&nbsp;Condition:" Width="138px"/></td>
                            <td><accenture:LengthLimitedMultilineTextBox ID="txtQueryCondition" runat="server" Text='<%# Bind("QueryCondition") %>' style="width:500px" TextMode="MultiLine" MaxLength="1000" Height="100px" CssClass="txtbox" /></td>
                        </asp:Panel>
                    </tr>
                </table>
            </EditItemTemplate>
            <InsertItemTemplate>
                Gid: <asp:TextBox ID="GidTextBox" runat="server" Text='<%# Bind("Gid") %>' /><br />
                GroupName: <asp:TextBox ID="GroupNameTextBox" MaxLength="50" runat="server" Text='<%# Bind("GroupName") %>' /><br />
                Id: <asp:TextBox ID="IdTextBox" runat="server" Text='<%# Bind("Id") %>'></asp:TextBox><br />
                GroupDescr: <asp:TextBox ID="GroupDescrTextBox" MaxLength="255" runat="server" Text='<%# Bind("GroupDescr") %>' /><br />
                ExcludeFromUserFilter: <asp:CheckBox ID="chbExcludefromDocFilter" runat="server" Checked='<%# Bind("ExcludeFromUserFilter") %>' /><br />
                Members: <asp:TextBox ID="MembersTextBox" runat="server" Text='<%# Bind("Members") %>' /><br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
            <ItemTemplate>
                Gid: <asp:Label ID="GidLabel" runat="server" Text='<%# Bind("Gid") %>' /><br />
                GroupName: <asp:Label ID="GroupNameLabel" runat="server" Text='<%# Bind("GroupName") %>' /><br />
                Id: <asp:Label ID="IdLabel" runat="server" Text='<%# Bind("Id") %>' /><br />
                GroupDescr: <asp:Label ID="GroupDescrLabel" runat="server" Text='<%# Bind("GroupDescr") %>' /><br />
                <%--ExcludeFromUserFilter: <asp:Label ID="lblExcludefromDocFilter" runat="server" Text='<%# Bind("ExcludeFromUserFilter") %>' /><br />--%>
                Members: <asp:Label ID="MembersLabel" runat="server" Text='<%# Bind("Members") %>' /><br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
            </ItemTemplate>
        </asp:FormView>
        <asp:Label ID="lblMsg" runat="server" ForeColor="Red" />
        <asp:ObjectDataSource ID="PermGroupObjectDataSource1" runat="server" DataObjectTypeName="Accenture.CSTPrague.eAPI.PermGroup" SelectMethod="FetchPermGroupFromDB" TypeName="Accenture.CSTPrague.eAPI.WebDB_Perm" UpdateMethod="StorePermGroupToDB" OnUpdating="PermGroupObjectDataSource1_Updating">
            <SelectParameters>
                <asp:SessionParameter Name="o" SessionField="oPermGroup" Type="Object" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</form>

CausesValidation="false"不起作用

设置ValidationGroup="dddd"在验证控件和想要的按钮

编辑

因为你在使用formview所以你遇到了这个问题。

请查看同样的问题已解决威胁