title: User Control with Client + Server Side CustomValidation; Wrong Client side validator is picked
body: <p>I have a user control which contains a CustomValidator which is used according to whether a RadioButton is checked or not (there are several RadioButtons, I'm only showing the relevant one)</p>
  
  <pre><code>&lt;asp:RadioButton runat="Server" ID="RadioBetween" GroupName="DateGroup" CssClass="date_group_options_control_radio" /&gt;
  &lt;asp:TextBox ID="FromDate" runat="server" Columns="8"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:TextBox ID="ToDate" runat="server" Columns="8"&gt;&lt;/asp:TextBox&gt;
  
  &lt;asp:CustomValidator ID="DateValidator" runat="server" Display="Dynamic" ClientValidationFunction="ValidateDateFields_Client" OnServerValidate="ValidateDateFields"&gt;&lt;/asp:CustomValidator&gt;
  </code></pre>
  
  <p>There is some client + server side validation code (the server side code does exactly the same thing and is skipped for brevity)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function ValidateDateFields_Client(source, args)
  {
      if ("&lt;%=EnableValidation%&gt;" == "True")
      {
          var bRadioBetweenSelected = false;
  
          var oRadio = document.getElementById('&lt;%=RadioBetween.ClientID%&gt;');
          if (oRadio != null &amp;&amp; (oRadio.checked == true || oRadio["checked"] == true))
          {
              bRadioBetweenSelected = true;
          }
  
          if (bRadioBetweenSelected)
          {
              var oFromDate = document.getElementById('&lt;%=FromDate.ClientID%&gt;');
              var oToDate = document.getElementById('&lt;%=ToDate.ClientID%&gt;');
  
              if (oFromDate != null &amp;&amp; oToDate != null)
              {
                  var sFromDate = oFromDate.value;
                  var sToDate = oToDate.value;
  
                  source.innerHTML = ValidateFromToDate(sFromDate, sToDate, args);
  
                  if (!args.IsValid)
                  {
                      return;
                  }
              }
              else
              {
                  args.IsValid = true;
              }
          }
          else
          {
              args.IsValid = true;
          }
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>There are two instances of this control in the page. When running the client side version it hits the wrong one (the version of the control which is disabled). You can see from the generated HTML both are correctly specified. I'm not sure how .NET works out which clientside function to call given they both have the same name. </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  var ctl00_MCPH1_QueryTextValidator = document.all ? document.all["ctl00_MCPH1_QueryTextValidator"] : document.getElementById("ctl00_MCPH1_QueryTextValidator");
  ctl00_MCPH1_QueryTextValidator.controltovalidate = "ctl00_MCPH1_SearchTextBox";
  ctl00_MCPH1_QueryTextValidator.focusOnError = "t";
  ctl00_MCPH1_QueryTextValidator.display = "Dynamic";
  ctl00_MCPH1_QueryTextValidator.evaluationfunction = "CustomValidatorEvaluateIsValid";
  ctl00_MCPH1_QueryTextValidator.clientvalidationfunction = "ValidateQueryText_Client";
  ctl00_MCPH1_QueryTextValidator.validateemptytext = "true";
  var ctl00_MCPH1_DisplayOptionsControl1_DateValidator = document.all ? document.all["ctl00_MCPH1_DisplayOptionsControl1_DateValidator"] : document.getElementById("ctl00_MCPH1_DisplayOptionsControl1_DateValidator");
  ctl00_MCPH1_DisplayOptionsControl1_DateValidator.display = "Dynamic";
  ctl00_MCPH1_DisplayOptionsControl1_DateValidator.evaluationfunction = "CustomValidatorEvaluateIsValid";
  ctl00_MCPH1_DisplayOptionsControl1_DateValidator.clientvalidationfunction = "ValidateDateFields_Client";
  var ctl00_MCPH1_PreferencesControl1_PreferencesTabContainer_DisplayOptionsTab_DisplayOptionsControl_DateValidator = document.all ? document.all["ctl00_MCPH1_PreferencesControl1_PreferencesTabContainer_DisplayOptionsTab_DisplayOptionsControl_DateValidator"] : document.getElementById("ctl00_MCPH1_PreferencesControl1_PreferencesTabContainer_DisplayOptionsTab_DisplayOptionsControl_DateValidator");
  ctl00_MCPH1_PreferencesControl1_PreferencesTabContainer_DisplayOptionsTab_DisplayOptionsControl_DateValidator.display = "Dynamic";
  ctl00_MCPH1_PreferencesControl1_PreferencesTabContainer_DisplayOptionsTab_DisplayOptionsControl_DateValidator.evaluationfunction = "CustomValidatorEvaluateIsValid";
  ctl00_MCPH1_PreferencesControl1_PreferencesTabContainer_DisplayOptionsTab_DisplayOptionsControl_DateValidator.clientvalidationfunction = "ValidateDateFields_Client";
  //]]&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Do i need to add something in to scope it? What's the best way to achieve this? If I disable the loading of the second control everything works fine. </p>