我有三个面板,每次由用户切换一次。在其中一个面板中,我有一些验证器控件。现在,乳清他们尝试提交表单数据时会弹出一些东西。好的。但在另一个面板上我也有一些按钮。当按下这些按钮时,没有回发,因为在另一个面板上弹出了必填字段,表示缺少这些字段。 (但用户实际上并没有使用这些文本框。
这是我的代码。
<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/Masters/LeftBar.master" AutoEventWireup="true" CodeFile="Request.aspx.cs" Inherits="Pages_Contents_Request" EnableViewState="true" %>
<asp:Content ID="HeadContent" ContentPlaceHolderID="LeftBarHeadContent" Runat="Server">
<link href="../StyleSheets/Content_Common.css" rel="stylesheet" type="text/css" />
<link href="../StyleSheets/Request_Content.css" rel="stylesheet" type="text/css"/>
<script src="../../Scripts/Contents_Common.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="TopBoxContent" ContentPlaceHolderID="TopBoxContentHolder" Runat="Server">
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContentPlaceHolder" Runat="Server">
<asp:ScriptManager ID="RequestScriptManager" runat="server"></asp:ScriptManager>
<div class="ItemHeaderSpace">
<div class="TitleWrapper">
<div class="ItemHeader">
<div class="ItemTitle">
Submit your request
</div>
<div class="ItemInfo">
</div>
</div>
<div id="SocialButtonsHolder" class="SocialButtons" runat="server">
</div>
</div>
<ul class="ItemProfileNav">
<li id="SubmitTab" class="Script_Tab ItemProfileNavInactive" runat="server">Sumbit request</li>
<li id ="CheckTab" class="Script_Tab ItemProfileNavInactive" runat="server">Check request status</li>
<li id="ViewTab" class="Script_Tab ItemProfileNavInactive" runat="server">View all request</li>
</ul>
</div>
<div class="ItemSpace">
<div class="ItemTabContent">
<div id="SubmitTabContent" class="Script_TabContent" runat="server">
<asp:UpdatePanel ID="SubmitRequestUpdatePanel" runat="server">
<ContentTemplate>
<div id="MessegeBox" class="ErrorBox" style="margin-bottom: 15px;" runat="server">
<p>Please try to find your content on our <a href="Index.aspx" target="_blank">index page</a>. Go to that content (<a href="Index.aspx?type=psvita" target="_blank">Games</a>, <a href="Index.aspx?type=movie>" target="_blank">Movies</a>) and request from there.
Creating a custom request will take more time for processing.
</p>
</div>
<table id="SubmitRequestForm" runat="server" class="DownloadInfoTable" style="width: 100%;">
<tr>
<td class="InfoField">Content Name: </td>
<td><asp:TextBox ID="ContentTitleTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="InfoField">Content Type: </td>
<td>
<asp:DropDownList ID="ContentTypeDropDown" runat="server">
<asp:ListItem Selected="True" Text="PS Vita Game" Value="psvita"></asp:ListItem>
<asp:ListItem Selected="False" Text="PSP ISO" Value="psp"></asp:ListItem>
<asp:ListItem Selected="False" Text="Movie" Value="movie"></asp:ListItem>
<asp:ListItem Selected="False" Text="TV Show Episode" Value="episode"></asp:ListItem>
<asp:ListItem Selected="False" Text="TV Show" Value="tvshow"></asp:ListItem>
</asp:DropDownList>
<asp:HiddenField ID="TypeHiddenFiled" runat="server" />
</td>
</tr>
<tr>
<td class="InfoField">Your Name*: </td>
<td>
<asp:TextBox ID="NameTextBox" MaxLength="200" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="NameValidator" CssClass="ErrorBox" ControlToValidate="NameTextBox" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="InfoField">Your date of birth*: </td>
<td>
<asp:DropDownList ID="YearDropdown" runat="server">
<asp:ListItem Selected="True" Text="Year" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="MonthDropdown" runat="server" AutoPostBack="true">
<asp:ListItem Selected="True" Text="Month" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DateDropdown" runat="server">
<asp:ListItem Selected="True" Text="Day" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:CompareValidator ID="YearValidator" CssClass="ErrorBox" runat="server" ControlToValidate="YearDropdown" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="*"></asp:CompareValidator>
<asp:CompareValidator ID="MonthValidator" CssClass="ErrorBox" runat="server" ControlToValidate="MonthDropdown" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="*"></asp:CompareValidator>
<asp:CompareValidator ID="DayValidator" CssClass="ErrorBox" runat="server" ControlToValidate="DateDropdown" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="*"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="InfoField">You are a: </td>
<td>
<asp:DropDownList ID="GenderDropdown" runat="server">
<asp:ListItem Selected="True" Text="Boy" Value="male"></asp:ListItem>
<asp:ListItem Selected="False" Text="Girl" Value="female"></asp:ListItem>
<asp:ListItem Selected="False" Text="Don't want to specify" Value="unspecified"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="InfoField">Your E-mail*: </td>
<td>
<asp:TextBox ID="EmailTextBox" runat="server" MaxLength="200"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequitedValidator" runat="server" ControlToValidate="EmailTextBox" ErrorMessage="*" CssClass="ErrorBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="InfoField">Your Profile Link (Optional): </td>
<td>
<asp:TextBox ID="ProfileLink" runat="server" MaxLength="500"></asp:TextBox></td>
</tr>
<tr>
<td class="InfoField"></td>
<td>
<asp:RegularExpressionValidator ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ID="EmailValidator" CssClass="ErrorBox" ControlToValidate="EmailTextBox" runat="server" ErrorMessage="That's not a valid Email address."></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td></td>
<td>
<span class="ErrorBox">All * marked fields are mandatory.</span>
</td>
</tr>
<tr>
<td class="InfoField"></td>
<td>
<asp:Button ID="SubmitRequestButton" runat="server" Text="Submit your Request" CssClass="MetroButtonText SubmitButton" /></td>
</tr>
</table>
<div class="Clearfix">
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="CheckTabContent" class="Script_TabContent" runat="server">
<asp:UpdatePanel ID="CheckRequestPanel" runat="server">
<ContentTemplate>
<table class="DownloadInfoTable" style="width: 520px;">
<tr>
<td class="InfoField">Your Request ID: </td>
<td>
<asp:TextBox ID="RequestIdTextBox" runat="server"></asp:TextBox><asp:Button ID="CheckStatusButton" runat="server" Text="Check status" CssClass="MetroButtonText" />
</td>
</tr>
<tr>
<td class="InfoField"></td>
<td>
<asp:Button ID="ForgotIDButton" CssClass="MetroButtonText" runat="server" Text="Forgot ID" />
</td>
</tr>
</table>
<div id="RequestCheckMessegeBox" class="ErrorBox" style="margin-bottom: 15px;" visible="false" runat="server">
<p>
</p>
</div>
<table id="RequestDetailsTable" class="DownloadInfoTable PopUpForm" runat="server" visible="false">
<tr>
<td class="InfoField">Hi, <asp:Label ID="RequestUserName" runat="server" Text="Label" Font-Bold="True" ForeColor="Black"></asp:Label></td>
<td>
</td>
</tr>
<tr>
<td class="InfoField">Your Request ID: </td>
<td>
<asp:Label ID="RequestIdLabel" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="InfoField">Request submission date: </td>
<td>
<asp:Label ID="RequestDateLabel" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="InfoField">Status: </td>
<td>
<asp:Label ID="StatusLabel" runat="server" Text="Label" Font-Bold="True" Font-Italic="True"></asp:Label>
</td>
</tr>
<tr id="TimeRemainingRow" runat="server" visible="false">
<td class="InfoField">Time remaining: </td>
<td>
<asp:Label ID="TimeRemainingLabel" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="InfoField">Resolving date: </td>
<td>
<asp:Label ID="ResolvingDate" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="InfoField">Requested Content: </td>
<td>
<asp:Hyperlink ID="RequestContentLink" runat="server" Text="Label"></asp:Hyperlink>
</td>
</tr>
<tr>
<td class="InfoField">Requested Content Type: </td>
<td>
<asp:Hyperlink ID="RequestedContentTypeLink" runat="server" Text="Label"></asp:Hyperlink>
</td>
</tr>
</table>
<table id="ForgotIDForm" class="DownloadInfoTable PopUpForm" runat="server" visible="false">
<tr>
<td class="InfoField">Your Name*: </td>
<td>
<asp:TextBox ID="ForgotIDNameTextBox" runat="server" Enabled="True" MaxLength="200"></asp:TextBox>
</td>
</tr>
<tr>
<td class="InfoField">Your Date of Birth*: </td>
<td>
<asp:DropDownList ID="ForgotIDMonthDropdown" runat="server">
<asp:ListItem Selected="True" Text="Month" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ForgotIDDateDropdown" runat="server">
<asp:ListItem Selected="True" Text="Day" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ForgotIDYearDropdown" runat="server">
<asp:ListItem Selected="True" Text="Year" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:CompareValidator ID="ForgotIdMonthVal" CssClass="ErrorBox" runat="server" ControlToValidate="ForgotIDMonthDropdown" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="*"></asp:CompareValidator>
<asp:CompareValidator ID="ForgotIdDateVal" CssClass="ErrorBox" runat="server" ControlToValidate="ForgotIDDateDropdown" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="*"></asp:CompareValidator>
<asp:CompareValidator ID="ForgotIdYearVal" CssClass="ErrorBox" runat="server" ControlToValidate="ForgotIDYearDropdown" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="*"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="InfoField">Your E-mail*: </td>
<td>
<asp:TextBox ID="ForgotIDEmailTextBox" runat="server" MaxLength="200"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="FindIDButton" CssClass="MetroButtonText" runat="server" Text="Find my Request ID" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="ViewTabContent" class="Script_TabContent" runat="server">
<asp:UpdatePanel ID="ViewRequestListUpdatePanel" runat="server">
<ContentTemplate>
<table class="DownloadInfoTable PopUpForm">
<tr>
<td>
<span class="InfoField"><asp:CheckBox ID="CheckBox1" Text="Show only pending requests" runat="server" /></span>
</td>
<td>
</td>
</tr>
<tr>
<td>
<span class="InfoField">Number of Requests: </span>
</td>
<td>
<asp:DropDownList ID="RequestNumDropdown" runat="server">
<asp:ListItem Selected="True" Text="20" Value="20"></asp:ListItem>
<asp:ListItem Selected="False" Text="40" Value="40"></asp:ListItem>
<asp:ListItem Selected="False" Text="All requests" Value="0"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<span class="InfoField">Sort requests by: </span>
</td>
<td>
<asp:DropDownList ID="SortDropdown" runat="server">
<asp:ListItem Selected="True" Text="Most Recent" Value=""></asp:ListItem>
<asp:ListItem Selected="False" Text="Content-wise" Value=""></asp:ListItem>
<asp:ListItem Selected="False" Text="Number of requests" Value=""></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
<table class="RequestListTable">
<thead>
<tr>
<th class="RequestIdCol">Request ID</th>
<th class="DateCol">Date</th>
<th class="ContentCol">Content</th>
<th class="RequestNoCol">No. of requests</th>
<th class="StatusCol">Status</th>
<th class="RequestedByCol">Request by</th>
<th class="ResolvingDateCol">Resoving date</th>
</tr>
</thead>
<tbody>
<tr>
<td class="RequestIdCol">DKFJD09</td>
<td class="DateCol">01 Jan,2012</td>
<td class="ContentCol">Batman Begins</td>
<td class="RequestNoCol">5</td>
<td class="StatusCol">Pending</td>
<td class="RequestedByCol">kaushikdb</td>
<td class="ResolvingDateCol">01 Jan,2012</td>
</tr>
</tbody>
</table>
<asp:Button ID="ViewMoreButton" CssClass="MetroButtonText LeftFloatButton" runat="server" Text="View More" />
<div class="Clearfix"></div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<script type="text/javascript">
$(document).ready(function () {
ItemTabSwitch();
FileScroll();
DownloadButton();
});
</script>
</div>
<div class="CommentBox">
<div class="DivTitle">Comments on <asp:Hyperlink ID="CommentHeader" runat="server" Text="Label"></asp:Hyperlink> Vitagamer</div>
<div id="Comments" class="Comments" runat="server"></div>
</div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="AddHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="SideContentPlaceHolder" Runat="Server">
</asp:Content>
我需要能够限制用户仅在忘记该面板上的内容时才提交表单。我希望其他面板上的按钮能够在按下时回发。
有什么工作?
谢谢。
答案 0 :(得分:1)
为每个面板使用验证组。如果未指定验证组,ASP.NET将触发表单上的所有验证器。
<div id="panel1">
<asp:requiredfieldvalidator id="RequiredFieldValidator1"
controltovalidate="NameTextBox"
validationgroup="PersonalInfoGroup"
errormessage="Enter your name."
runat="Server">
</asp:requiredfieldvalidator>
<asp:button id="Button1"
text="Validate"
causesvalidation="true"
validationgroup="PersonalInfoGroup"
runat="Server" />
</div>
<div id="panel2">
<asp:requiredfieldvalidator id="RequiredFieldValidator2"
controltovalidate="NameTextBox2"
validationgroup="PersonalInfoGroup2"
errormessage="Enter your name."
runat="Server">
</asp:requiredfieldvalidator>
<asp:button id="Button2"
text="Validate"
causesvalidation="true"
validationgroup="PersonalInfoGroup2"
runat="Server" />
</div>