Loading ...

Validation controls

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  web forms / data controls   » Validation controls

Validation controls

Posts under the topic: Validation controls

Posted: 7/11/2011

Lurker 15  points  Lurker
  • Joined on: 7/11/2011
  • Posts: 3

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" />

<br />

<asp:Button ID="btnCancelTimeCodes2" runat="server" Text="Cancel" />

<asp:Button ID="btnSaveAndexit2" runat="server" Text="Save &amp; 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


Posted: 7/11/2011

Starter 727  points  Starter
  • Joined on: 6/6/2011
  • Posts: 74

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

Lurker 117  points  Lurker
  • Joined on: 6/2/2009
  • Posts: 10

You would add attribute  validationgroup into button btnLoadTimesforTimeCode and RequiredTimeCode controls.


Page 1 of 1 (3 items)