title: Embedded Javascript in Master Page or Pages That Use Master Page throw "Object Expected Error"
body: <p>I'm semi-new to writing ASP.Net applications using master pages and I've run into an issue I've spent some time on but can't seem to solve.</p>
  
  <p>My situation is that I have a master page with a structure that looks like this:</p>
  
  <pre><code>&lt;head runat="server"&gt; 
      &lt;title&gt;Test Site&lt;/title&gt;   
      &lt;link rel="Stylesheet" type="text/css" href="Default.css" /&gt;
      &lt;script type="text/javascript" language="javascript" src="js/Default.js" /&gt;
      &lt;meta http-equiv="Expires" content="0"/&gt;
      &lt;meta http-equiv="Cache-Control" content="no-cache"/&gt;
      &lt;meta http-equiv="Pragma" content="no-cache"/&gt;        
      &lt;asp:ContentPlaceHolder ID="cphHead" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;       
  
          &lt;div id="divHeader"&gt;
          &lt;asp:ContentPlaceHolder ID="cphPageTitle" runat="server"&gt;&lt;/asp:ContentPlaceHolder&gt;
          &lt;/div&gt;
  
          &lt;div id="divMainContent"&gt;
          &lt;asp:ContentPlaceHolder ID="cphMainContent" runat="server"&gt;&lt;/asp:ContentPlaceHolder&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I then have a page that uses this master page that contains the following:</p>
  
  <pre><code>&lt;asp:Content ContentPlaceHolderID="cphHead" runat="server"&gt;   
      &lt;script type="text/javascript" language="javascript" &gt;    
  
          function test() {
              alert("Hello World");
          }
   &lt;/script&gt;
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ContentPlaceHolderID="cphMainContent" runat="server"&gt;
      &lt;fieldset&gt;          
          &lt;img alt="Select As Of Date" src="Images/Calendar.png" id="aAsOfDate" class="clickable" runat="server" onclick="test();" /&gt;            
          &lt;asp:Button runat="server" CssClass="buttonStyle" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Clicked"/&gt;            
      &lt;/fieldset&gt; 
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>When I run this page and click on the image I get an <code>"Object Expected"</code> error.</p>
  
  <p>However, if I place the test function into my Default.js external file it will function perfectly.</p>
  
  <p>I can't seem to figure out why this is happening. Any ideas?</p>