我有一个文本框,按下链接按钮时启用该文本框。每次我删除文本框的内容并点击取消我希望它不做任何验证。它执行客户端验证,当我第二次点击取消时,页面会像它应该的那样返回。这是我的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 *~!@#$%^&*()|\\?/<>=+_]+$" 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 =“False”