我已经创建了一个用户控件并在其中使用了组验证,但我是组验证的新手,我知道必填字段是如何工作的,但在验证组中,我无法使用我自己的必需的归档验证器。有一些自定义验证器使用javascript在客户端工作。请指导我如何使用自定义验证器,验证组和javascript的组合来使用js显示错误消息
<cc1:ModalPopupExtender ID="ModalPopupExtender2" Y="20" X="10" runat="server" TargetControlID="Button2"
PopupControlID="pnlAddMoreOrEdit" BackgroundCssClass="ModalPoopup" BehaviorID="popup1"
CancelControlID="modalCancel" PopupDragHandleControlID="EmptyPanel" RepositionMode="none">
</cc1:ModalPopupExtender>
<%: System.Web.Optimization.Scripts.Render("~/Script/BusinessIncome44ADA")%>
<%--<script src="../../ITR_FY1617Assets/scripts/BusinessIncome44ADA.js" type="text/javascript"></script>--%>
<asp:Panel ID="pnlAddMoreOrEdit" runat="server" CssClass="ModalPopupPanel" Style="width: 900px;
display: none">
<div class="ModalHeader">
<asp:Label ID="lblAdd" runat="server" CssClass="msg" Text="Business Income"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="HeaderButton CGHeaderImage"
CausesValidation="false" OnClientClick="return Close();" style="background-image:url('../../images/close_pop.png');" />
</div>
<div class="ModalBody">
<div id="StepFive">
</div>
<div class="uspace">
<asp:ValidationSummary runat="server" ID="ValidationSummary1" ForeColor="" CssClass="ValidationSummary"
HeaderText=" Sorry, We need following information(s) to proceed further." ValidationGroup="G1">
</asp:ValidationSummary>
<div id="Step1">
<div class="Information">
<p>
Fill in the information of business income :
</p>
</div>
<p id="SubCatP" runat="server" style="display:none">
Suitable Area of Business
<asp:DropDownList ID="ddlSubCatP" runat="server" CssClass="DropDownList" onchange="RemoveColour(this)">
<asp:ListItem Selected="True" Value="0">Select</asp:ListItem>
<asp:ListItem Value="0601">Legal</asp:ListItem>
<asp:ListItem Value="0602">Medical</asp:ListItem>
<asp:ListItem Value="0603">Engineering or Architectural</asp:ListItem>
<asp:ListItem Value="0604">Accountancy</asp:ListItem>
<asp:ListItem Value="0605">Technical</asp:ListItem>
<asp:ListItem Value="0606">Interior decoration</asp:ListItem>
<asp:ListItem Value="06071">Authorised Representative</asp:ListItem>
<asp:ListItem Value="06072">Film Artist </asp:ListItem>
<asp:ListItem Value="06073">Company Secretary</asp:ListItem>
<asp:ListItem Value="06074">Professional of Information Technology</asp:ListItem>
<asp:ListItem Value="06077">Others</asp:ListItem>
</asp:DropDownList>
</p>
<p class="RBLPara">
Name of Trade
<asp:TextBox ID="txtNT" autocomplete="off" runat="server" MaxLength="100" CssClass="SimpleTextBox FloatRight IE6TextBox" onkeyup="RemoveColour(this)"/>
</p>
</div>
<div id="Step2">
<div id="ADDetails" style="display: none" runat="server">
<div class="Information">
<p>
Fill in the following information :
</p>
</div>
<p>
<span id="GrossTurnOver" runat="server">Gross Turnover / Receipts
</span>
<asp:TextBox ID="txtGTO" runat="server" autocomplete="off" onkeypress="return AllowNum(event);" MaxLength="8" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" CssClass="SimpleTextBox FloatRight IE6TextBox" onkeyup="checkGTO(this)" onblur="calProfit()"/>
</p>
<p id="Expense" runat="server" style="display:none">
Expenses
<asp:TextBox ID="txtExpenses" runat="server" autocomplete="off" onkeypress="return AllowNum(event);" MaxLength="8" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" CssClass="SimpleTextBox FloatRight IE6TextBox" onkeyup="checkGTO(this)" onblur="calProfit()"/>
</p>
<p>
<span id="NetProf" runat="server">Net Profit / Income
</span>
<asp:TextBox ID="txtIncome" runat="server" ValidationGroup="G3" autocomplete="off" onkeypress="return AllowNegNum(event);" MaxLength="8" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" CssClass="SimpleTextBox FloatRight IE6TextBox" onkeyup="checkGTO(this)" />
</p>
</div>
<div class="SundryDetails" id="SundryDetails" runat="server" style="display: none">
<p runat="server">
Sundry Debtors
<asp:TextBox ID="txtSD" autocomplete="off" runat="server" placeholder="If any" onkeypress="return AllowNum(event);" MaxLength="8" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" CssClass="SimpleTextBox FloatRight IE6TextBox" />
</p>
<p runat="server">
Sundry Creditors
<asp:TextBox ID="txtSC" autocomplete="off" runat="server" placeholder="If any" onkeypress="return AllowNum(event);" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" MaxLength="8" CssClass="SimpleTextBox FloatRight IE6TextBox" />
</p>
<p id="StockInTrade" runat="server">
Stock in Trade
<asp:TextBox ID="txtST" autocomplete="off" runat="server" placeholder="If any" onkeypress="return AllowNum(event);" MaxLength="8" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" CssClass="SimpleTextBox FloatRight IE6TextBox" />
</p>
<p runat="server">
Cash Balance
<asp:TextBox ID="txtCB" autocomplete="off" runat="server" placeholder="If any" onkeypress="return AllowNum(event);" MaxLength="8" style="background-image: url('../../images/Rs_Symbol.png');
background-repeat:no-repeat;background-position: 5px;text-align: right;" CssClass="SimpleTextBox FloatRight IE6TextBox" />
</p>
</div>
</div>
<div id="Step3" style="display:none">
<div class="Information">
<p>
You are required to fill Books of accounts
</p>
</div>
</div>
</div>
</div>
<div class="ModalFooter" id="footer" runat="server">
<a id="modalBack" class="modal" style="display: none" runat="server" causesvalidation="false"
onclick="return GoBack();">Go Back</a>
<a id="modalCancel" class="modal" runat="server" onclick="return Close();">Cancel</a>
<a id="modalSave" class="modal" runat="server" onserverclick="Save" onclick="return NextStep();">Next Step</a>
<a id="modalTemp" class="modal" runat="server" style="display: none">Saving..</a>
<div id="mycss" style="background-color: #f2f2f2;height:15px;display:none;margin-bottom:20px;">
<a id="A1" class="modal" style="background-color: #5fb336;float:right;color:white;padding:10px;" runat="server" href="BusinessIncomeBookOfAC.aspx">Continue to Books Of Accounts</a>
</div>
</div>
<asp:Button ID="Button2" runat="server" Style="display: none" Text="Button" />
</asp:Panel>
<asp:Panel ID="EmptyPanel" runat="server">
</asp:Panel>
<asp:HiddenField ID="hfSteps" runat="server" Value="0" />
<asp:HiddenField ID="hfId" runat="server" Value="0" />
<asp:HiddenField ID="hfadmore" Value="1" runat="server" />
<asp:HiddenField ID="hfErrordiv" Value="0" runat="server" />
<asp:HiddenField ID="hfPan" runat="server" Value="" />
<asp:CustomValidator ID="CV1" runat="server" ValidationGroup="G1"
ClientValidationFunction="Validate_FreeLance" ForeColor="White"
ErrorMessage="Please Select Sub Category">*</asp:CustomValidator>
<asp:CustomValidator ID="CV2" runat="server" ValidationGroup="G2"
ClientValidationFunction="Validate_Business" ForeColor="White"
ErrorMessage="Please Select Suitable Area of Business.">*</asp:CustomValidator>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtNT"
ID="RequiredFieldValidator1" ValidationGroup="G1" ForeColor="White" ErrorMessage="Please Provide Name of Trade.">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtIncome"
ID="as" ValidationGroup="G3" ForeColor="White" ErrorMessage="Please Provide Name of Trade.">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtGTO"
ValidationGroup="G3" ForeColor="White" ErrorMessage="Please Provide Gross Turn Over." >*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="a8" runat="server" ControlToValidate="txtIncome"
ValidationGroup="G3" ForeColor="White" ErrorMessage="Please Provide Income.">*</asp:RequiredFieldValidator>
<%--<asp:CustomValidator ID="CustomValidator11" runat="server" ValidationGroup="G3"
ClientValidationFunction="Validate_Income" ForeColor="red">*</asp:CustomValidator>--%>
答案 0 :(得分:0)
您还必须在按钮中提及ValidationGroup
<asp:Button ID="Button2" runat="server" Style="display: none" Text="Button" ValidationGroup="G1" />
例如,当您必须在提交按钮中验证某些内容时,单击将相同的组分配给您提交的控件。