title: How to use an external javascript file in asp.net
body: <p>I wrote a script to hide and show a loader for my asp.net web application. The script works great when placed inline. I tried to extract the script to an external file and received the following error:</p>
  
  <p><strong>Error:</strong> The value of the property 'Pausing' is null or undefined, not a Function object</p>
  
  <p>I tried to look up the error, but I was unable to find a solution to the problem. I am new to asp.net so it may be that I'm not sure how to search for the right question.</p>
  
  <p>My inline code that works is:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      function Pausing() {
          window.setTimeout(ShowLoader, 1);
      }
  
      function ShowLoader() {
          if ((typeof Page_IsValid === 'undefined') || 
              (Page_IsValid != null &amp;&amp; Page_IsValid)) {
              var i = document.getElementById("loader");
              var img = document.getElementById("img");
              i.style.display = "block";
              setTimeout("document.images['img'].src=document.images['img'].src", 10);
              Endpausing();
          }
      }
  
      function HideLoader() {
          var i = document.getElementById("loader");
          i.style.display = "none";
      }
  
      function Endpausing() {
          window.setTimeout(HideLoader, 4000);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>The event call is attached to an asp:button control below:</p>
  
  <pre><code>&lt;asp:Button ID="btnGetReport" runat="server" OnClick="btnGetReport_Click" OnClientClick="Pausing();" /&gt;
  </code></pre>
  
  <p>I removed the inline script and replaced with this...</p>
  
  <pre><code>&lt;script type="text/javascript" src="../../Scripts/Loader.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Added script to external file:</p>
  
  <pre><code>window.onload = initAll;
  
  function initAll() {
  
      function Pausing() {
          window.setTimeout(ShowLoader, 1);
      }
  
      function ShowLoader() {
          if ((typeof Page_IsValid === 'undefined') ||      // asp page has no validator
                  (Page_IsValid != null &amp;&amp; Page_IsValid)) {
              var i = document.getElementById("loader");
              var img = document.getElementById("img");
              i.style.display = "block";
              setTimeout("document.images['img'].src=document.images['img'].src", 10);
              Endpausing();
          }
      }
  
      function HideLoader() {
          var i = document.getElementById("loader");
          i.style.display = "none";
      }
  
      function Endpausing() {
          window.setTimeout(HideLoader, 4000);
      }
  }
  </code></pre>
  
  <p>Then I receive the previously mentioned error.</p>
  
  <p>Any help would be greatly appreciated!</p>