2012-05-17 136 views
0

我有一個文本框,當按下鏈接按鈕時啓用。每次我刪除文本框的內容並點擊取消我希望它不做任何驗證。它執行客戶端驗證,當我第二次點擊取消時,頁面會回到它應該的狀態。這是我的HTML。我真的需要弄清楚這一點。謝謝。驗證無法正常工作

<%@ Page Title="Account Activation Deactivation Reasoning" Language="C#" MasterPageFile="~/Forms/Site.master" 
AutoEventWireup="True" CodeBehind="ActivationDeactivationReasons.aspx.cs" Inherits="AccountManagementAdmin.UserInterface.Forms.ActivateDeactivateReasons.ActivationDeactivationReasons" %> 

<%@ MasterType VirtualPath="~/Forms/Site.Master" %> 
<asp:Content ID="cphAccNumberLookup" runat="server" ContentPlaceHolderID="cphPageContent"> 
    <div class="ContentPage"> 
     <div class="ContentPageHeader"> 
      Activation/Deactivation Account Reasons 
     </div> 
      <asp:Panel runat="server" EnableViewState="false" ID="pnlMessage" Visible="false"> 
        <asp:Label runat="server" ID="lblValidationMessage" EnableViewState="false" /> 
      </asp:Panel> 
     <br /> 
     <div class="SubSection"> 
      <div class="SubSectionHeader"> 
       Add Activation/Deactivation Reason 
      </div> 
      <table> 
       <tr> 
        <td> 
         <asp:Label ID="lblReason" runat="server" Text="Enter Reason:"></asp:Label> 
        </td> 
        <td> 
         <asp:TextBox ID="txtNewReason" runat="server" MaxLength="30" Width="206px"></asp:TextBox> 
        </td> 
        <td> 
         <asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="Button" OnClick="btnAdd_Click"> 
         </asp:Button> 
        </td> 
       </tr> 
      </table> 
     </div> 
     <br /> 
     <div> 
      <table> 
       <asp:Repeater runat="server" ID="rptReasons" 
        onitemcommand="rptReasons_ItemCommand"> 
        <HeaderTemplate> 
         <thead> 
          <tr> 
           <th class="GridHeader"> 
            Reason 
           </th> 
           <td class="GridHeader"> 
           </td> 
          </tr> 
         </thead> 
        </HeaderTemplate> 
        <ItemTemplate> 
         <tr> 
          <td class="GridRow" style="text-align: left;"> 
           <asp:Label runat="server" ID="lblValue" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'/> 
           <asp:TextBox runat="server" ID="txtValue" ValidationGroup="validationGroup" Visible="false" Width="550" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' /> 
           <asp:RequiredFieldValidator ID="rfvReasons" runat="server" ValidationGroup="validationGroup" ControlToValidate="txtValue" Display="Dynamic" ErrorMessage="Reason Cannot Be Empty"/> 
           <asp:RegularExpressionValidator runat="server" ID="regxValidator" ControlToValidate="txtValue" Display="Dynamic" ValidationExpression="^[A-Za-z0-9 *[email protected]#$%^&*()|\\?/<>=+_]+$" ErrorMessage="Reason Contains Invalid Characters"/> 
           </td> 
          <td class="GridRow" style="width: 80px;"> 
           <asp:LinkButton runat="server" ID="lbtnEdit" Text="Edit" CommandName="Edit"/> 
           <%--<asp:Panel runat="server" ID="pnlUpdateRow" Visible="false" >--%> 
            <asp:Button runat="server" ID="lbtnUpdate" Text="Update" CommandName="Update" CommandArgument= '<%# DataBinder.Eval(Container.DataItem, "Id") %>' Visible="False" ValidationGroup="validationGroup" CausesValidation="True"/> 
            <asp:Button runat="server" ID="lbtnCancel" Text="Cancel" CommandName="Cancel" Visible="False/> 
           <%--</asp:Panel>--%> 
          </td> 
         </tr> 
        </ItemTemplate> 
       </asp:Repeater> 
      </table> 
     </div> 
    </div> 
</asp:Content> 
+0

可以發佈您的代碼後面? –

回答

0

你的取消按鈕需要設置的CausesValidation =「假」

+0

我改變了CausesValidation =「False」,沒有任何變化。 – firexfighterx