Posted: 7/11/2011
I have a few required field validators as below
<asp:TextBox runat="server" ID="txtTimeCode" />
<asp:Button runat="server" ID="btnLoadTimesforTimeCode" Text="Load times for Time Code" />
<asp:RequiredFieldValidator ID="RequiredTimeCode" runat="server" ControlToValidate="txtTimeCode"ErrorMessage="TimeCode is a Required Field" />
<br />
<asp:TextBox runat="server" ID="txtTimeToAdd" CssClass="adminspecialrequirements" />
<asp:Button runat="server" ID="btnAdd" Text="Add" CssClass="button" />
<asp:RequiredFieldValidator ID="RequiredTimeToAdd" runat="server" ControlToValidate="txtTimeToAdd"ErrorMessage="Enter TimeTo Add" />
<asp:Button ID="btnCancelTimeCodes2" runat="server" Text="Cancel" />
<asp:Button ID="btnSaveAndexit2" runat="server" Text="Save & Exit" />
My issue is when i click btnLoadTimesforTimeCode i thought only RequiredTimeCode does the validation .....but even the RequirdTimetoAdd as well fires up.rather all the validations on the screen are fired.
To an extent i could resolve this adding validation groups which i dont want to .can you please help what wrong i am doing here
Hi Sril,
You should use validation group with validation controls.
I guess you would like to dissect validation when user click on one button to be validate one control, and on other button to be validate another control. This can be acheived with two validation groups.
On the following link you can see how you can use and specify validation groups:
http://msdn.microsoft.com/en-us/library/ms227424.aspx
Best Regards,
Gjorgji
Posted: 7/12/2011
You would add attribute validationgroup into button btnLoadTimesforTimeCode and RequiredTimeCode controls.