title: how to set RequiredFieldValidator to validate against specific user control which has multiple instance?
body: <p>so let say i have a user control which called 7 times in an aspx file, i put field validator control in that user control, the problem is everytime i click some buttons which cause postback, field validator always validate controls against all instances of my user control, what i want is to validate against specific user control, i have tried this :</p>
  
  <pre><code>&lt;asp:TextBox runat="server" ID="DateNew" CssClass="time" Width="185px"/&gt;
  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Date can not be empty" ControlToValidate="DateNew" ValidationGroup='&lt;%= ClientID %&gt;' Text="*"&gt; &lt;/asp:RequiredFieldValidator&gt; 
   &lt;asp:Button runat="server" ID="NewSchedule" Text="Schedule" CssClass="bgrey" 
          OnClientClick="CheckKeyValues()" OnClick="NewSchedule_Click"  ValidationGroup='&lt;%= ClientId %&gt;'/&gt;
  </code></pre>
  
  <p>this is not working... any correction? thanx before. btw some example would be great.</p>
  
  <p>update : aspx file with a user control called 7 times</p>
  
  <pre><code> &lt;asp:ScriptManager id="ScriptManager1" runat="server"&gt;
                          &lt;/asp:ScriptManager&gt;
                          &lt;div id="divError" class="n fail" style="display:none; margin:15px; width:2330px"&gt;
                               &lt;h5&gt;
                                  The following errors were found
                               &lt;/h5&gt;
                               &lt;asp:ValidationSummary ID="ValidationSummary" runat="server" /&gt;
                          &lt;/div&gt;    
                          &lt;div class="warea clearfix" style="width: 2350px"&gt;
                              &lt;div style="float:left;"&gt;
                                  &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress" TestType="Interview 1" /&gt;
                              &lt;/div&gt;
                               &lt;div style="float:left;"&gt;
                                  &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress1" TestType="Interview 2"/&gt;
                              &lt;/div&gt;
                               &lt;div style="float:left;"&gt;
                                 &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress2" TestType="Interview 3"/&gt;
                              &lt;/div&gt;
                               &lt;div style="float:left;"&gt;
                                  &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress3" TestType="English Test"/&gt;
                              &lt;/div&gt;
                               &lt;div style="float:left;"&gt;
                                  &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress4" TestType="Medical Examination"/&gt;
                              &lt;/div&gt;
                               &lt;div style="float:left;"&gt;
                                  &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress5" TestType="Internal Psycho Test"/&gt;
                              &lt;/div&gt;
                               &lt;div style="float:left;"&gt;
                                  &lt;uc1:ucApplicationProgress runat="server" id="ucApplicationProgress6" TestType="External Psycho Test"/&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  </code></pre>
  
  <p>user control file :</p>
  
  <pre><code> &lt;h3&gt;&lt;asp:Label runat="server" ID="TypeNew"/&gt;&lt;/h3&gt;
                &lt;table&gt;
                    &lt;tr&gt;
                       &lt;td&gt;Date&lt;/td&gt;
                       &lt;td&gt;
                           &lt;asp:TextBox runat="server" ID="DateNew" CssClass="time" Width="185px"/&gt;
                           &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Date can not be empty" ControlToValidate="DateNew"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                       &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Time&lt;/td&gt;
                        &lt;td&gt;
                            &lt;asp:TextBox runat="server" ID="HourNew"  Width="40px"/&gt; 
                            &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Time can not be empty" ControlToValidate="HourNew" Text="*"&gt;
                            &lt;/asp:RequiredFieldValidator&gt;:  
                            &lt;asp:TextBox runat="server" ID="MinuteNew"  Width="40px"/&gt;
                            &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Minute can not be empty" ControlToValidate="MinuteNew" Text="*"&gt;
                            &lt;/asp:RequiredFieldValidator&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Location&lt;/td&gt;
                        &lt;td&gt;
                            &lt;asp:TextBox runat="server" ID="LocationNew" TextMode="MultiLine"/&gt;
                            &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Location can not be empty" ControlToValidate="LocationNew" Text="*"&gt;
                            &lt;/asp:RequiredFieldValidator&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Interviewer&lt;/td&gt;
                        &lt;td&gt;
                            &lt;asp:TextBox runat="server" ID="InterviewerNew" autocomplete="off" onchange="MarkFlag(this.id)"/&gt;
                            &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Interviewer can not be empty" ControlToValidate="InterviewerNew" Text="*"&gt;
                            &lt;/asp:RequiredFieldValidator&gt;
                            &lt;asp:HiddenField runat="server" ID="InterviewerKeys"/&gt;
                            &lt;asp:HiddenField runat="server" ID="InterviewerEmail"/&gt;    
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                        &lt;td&gt;&lt;asp:Button runat="server" ID="NewSchedule" Text="Schedule" CssClass="bgrey" OnClientClick="CheckKeyValues()" OnClick="NewSchedule_Click" /&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
  </code></pre>
  
  <p>C# :</p>
  
  <pre><code> public String ValidationGroup
          {
              get 
              { 
                  return RequiredFieldValidator1.ValidationGroup;
              }
              set
              {
                  RequiredFieldValidator1.ValidationGroup = value;
                  RequiredFieldValidator2.ValidationGroup = value;
                  RequiredFieldValidator3.ValidationGroup = value;
                  RequiredFieldValidator4.ValidationGroup = value;
                  RequiredFieldValidator5.ValidationGroup = value;
                  NewSchedule.ValidationGroup = value;
              }
          }
  
  
    protected void Page_Load(object sender, EventArgs e)
          {
  
                  ValidationGroup = this.ID;
          }
  </code></pre>