Reputation: 61
[textbox1]
[textbox2]
[button1] [linkbutton1]
i have 2 textboxes
, 2 RequiredFieldValidator
, button1
and linkbutton
.
the button1 and 2textboxes are working properly with RequiredFieldValidator, but if i click the linkbutton the RequiredFieldValidator also appears.
I want the RequiredFieldValidator
focus only in button1
. Is this possible?
Upvotes: 0
Views: 2762
Reputation: 4892
Use
ValidationGroup
property ofRequiredFieldValidator
.
Set the ValidataionGroup="someName"
for your textbox1-requiredfieldvalidator
, textbox2- requiredfieldvalidator
and your button1
control.
Note: Keep the name of the ValidationGroup
same.
Upvotes: 0
Reputation: 40990
Set CausesValidation="false"
in your link button markup like this
<asp:LinkButton ID="lnkButton" runat="server" CausesValidation="false"></asp:LinkButton>
Upvotes: 3
Reputation: 12705
you need to specify Validation Groups
<asp:requiredfieldvalidator id="RequiredFieldValidator2"
controltovalidate="AgeTextBox"
validationgroup="PersonalInfoGroup"
errormessage="Enter your age."
runat="Server">
</asp:requiredfieldvalidator>
Upvotes: 0