title: WebUIValidation.js gets reloaded in async calls when in CompositeScript and UpdatePanel
body: <p><strong>My scenario:</strong></p>
  
  <ul>
  <li>I have a validator in an <code>UpdatePanel</code>.</li>
  <li>I want to combine my scripts so I am using <code>CompositeScript</code> in <code>ScriptManager</code>, and including a reference to <code>WebUIValidation.js</code></li>
  <li>I am using .NET 4.0</li>
  </ul>
  
  <p><strong>My problem:</strong></p>
  
  <ul>
  <li>When I asynchronously update the panel, .NET loads <code>WebUIValidation.js</code> (in a <code>Scriptresource.axd</code> file) in the async response, even though it has been loaded in the initial <code>CompositeScript</code>-generated script.  This is a problem because I have custom code that hijacks some functions in <code>WebUIValidation.js</code>, and the async response overrides my hijacks.</li>
  <li>If you move the reference to <code>WebUIValidation.js</code> to <code>Scripts</code> in <code>ScriptManager</code>, there is no problem.</li>
  <li>If you were to have <code>WebUIValidation.js</code> as the only item in <code>CompositeScript</code> (pointless I know) then there is no problem.</li>
  <li>This async reload does not happen with other .NET library scripts, e.g. <code>WebForm.js</code></li>
  </ul>
  
  <p><strong>What I want to find out:</strong></p>
  
  <ul>
  <li><strong><em>is there a reason why <code>WebUIValidation.js</code> is loaded in the async response when it is already included in the <code>CompositeScript</code>?</em></strong></li>
  </ul>
  
  <p>Someone has posted a <a href="https://stackoverflow.com/questions/20990271/use-local-version-of-webuivalidation-js-in-asp-net#20990271">similar (but not duplicate) issue</a> today, and is veering towards saying that <code>WebUIValidation.js</code> might not be handled by <code>ScriptManager</code>.  Can anyone verify this?</p>
  
  <p>To replicate use the following two files</p>
  
  <p><strong>test1.js</strong></p>
  
  <pre><code>// To be added to the composite script
  console.log('Test 1 Loaded');
  </code></pre>
  
  <p><strong>test.aspx</strong></p>
  
  <pre><code>&lt;%@ Page Language="vb" AutoEventWireup="false"  %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script language="VB" runat="server" runat="server"&gt;
          Protected Sub ButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles TestButton.Click
              ButtonClickFeedback.Text = "Button clicked At " &amp; Date.Now.ToString &amp; "; Look at the scripts in your Developer Tools, there is now a separate script for WebUIValidation.js loaded, in spite of the composite script."
          End Sub 
      &lt;/script&gt;
  
      &lt;form runat="server"&gt;
          &lt;asp:ScriptManager runat="server"&gt;
              &lt;CompositeScript&gt;
                  &lt;Scripts&gt;
                      &lt;asp:ScriptReference Path="~/test.js" /&gt;
                      &lt;asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" /&gt;
                  &lt;/Scripts&gt;
              &lt;/CompositeScript&gt;
          &lt;/asp:ScriptManager&gt;
  
          &lt;h1&gt;WebUIValidation.js, CompositeScript and UpdatePanel test&lt;/h1&gt;
  
          &lt;asp:UpdatePanel runat="server" ID="ButtonUpdatePanel"&gt;
              &lt;ContentTemplate&gt;
                  &lt;asp:Label runat="server" &gt;This is a section with a validator that is within an UpdatePanel.  If you look at the scripts loaded, you will see the composite script in the detail.&lt;/asp:Label&gt;
                  &lt;asp:Textbox ID="TestInputForValidator" runat="server" Text="This is populated so it will validate"/&gt;
                  &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="TestInputForValidator" ErrorMessage="You must write something" /&gt;&lt;br /&gt;
                  &lt;asp:Button ID="TestButton" Text="Click Me!" runat="server"  /&gt;&lt;br /&gt;
                  &lt;asp:Literal ID="ButtonClickFeedback" runat="server" /&gt;
              &lt;/ContentTemplate&gt;
              &lt;Triggers&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="TestButton" /&gt;
              &lt;/Triggers&gt;
          &lt;/asp:UpdatePanel&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If you use your Developer Tools to inspect what scripts are being loaded in, you should see an additional Scriptresource.axd (that contains WebUIValidation.js) getting loaded in after clicking the button, in spite of the existence of a Scriptresource.axd with the composite script.  test.js is just a sample js file to simulate the idea of composite scripts.</p>