validation group validations programatically in asp.net with vb.net as code behind

1.4k Views Asked by At

I have a panel, controls in the panel..these controls validated with a validation group.

This panel will show / hide when a dropdown box changes.

Question is...i want to validate all the controls with validation group in the panel

how to write the code

1

There are 1 best solutions below

0
On BEST ANSWER

You define validationgroup="Test" on your validators , and you define also this validationgroup="Test" on your Button.

Sample

     .....
     <asp:requiredfieldvalidator id="NameTextBoxRequiredValidator" 
        controltovalidate="NameTextBox"
        display="Dynamic" 
        text="Please enter your name."
        validationgroup="ForPanel"  <----------------
        runat="server"/>

      <asp:button id="SubmitButton"
        text="Submit"
        validationgroup="ForPanel"  <------------------
        runat="server"/>

Nota : Gets or sets the name of the validation group to which this validation control belongs.