Reputation: 273
I want to validate only part of the page in the same form.
However it validates whole pages textboxes like below. Here is the details;
Code behind is;
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
.
.
.
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnLogin" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
// the section that i want to validate only below textbox using reset button however above one is validating too
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="tbMailForgot" minlength="1" required="" runat="server" TextMode="Email" ValidateRequestMode="Enabled" ></asp:TextBox>
<asp:Button ID="btnReset" OnClientClick="return funcmail();" runat="server" Text="Reset" OnClick="btnReset_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnReset" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</form>
How can i do it partly ?
Upvotes: 0
Views: 170
Reputation: 21637
You can use Validation groups. You have to set each validator to a validation group and then set the same validation group to the submit button. For instance:
<asp:TextBox ID="tbMailForgot" minlength="1" required="" runat="server" TextMode="Email" ValidateRequestMode="Enabled"></asp:TextBox>
<asp:requiredfieldvalidator id="RequiredFieldValidator2"
controltovalidate="tbMailForgot"
validationgroup="Forgot"
errormessage="Email required"
runat="Server">
</asp:requiredfieldvalidator>
<asp:Button ID="btnReset" OnClientClick="return funcmail();" runat="server" Text="Reset" OnClick="btnReset_Click" ValidationGroup="Forgot" />
Upvotes: 1