title: Add Script Reference (JavaScript) to Script Manager on Microsoft AJAX Partial Postback
body: <p>I am trying to add a script reference to the script manager in the event of a Microsoft AJAX Partial Postback, ie a user clicks on a link in an Update Panel.</p>
  
  <pre><code>ScriptManager.RegisterClientScriptInclude(Page, Page.GetType(), "UniqueName",
                                            Page.ResolveUrl(scriptPath));
  </code></pre>
  
  <p>Doesn't work and either does</p>
  
  <pre><code>ScriptReference script = new ScriptReference(scriptPath);
  MyScriptManager.Scripts.Add(script);
  </code></pre>
  
  <p>From what I have read on the net, RegisterClientScriptInclude should work even in a partial postback.
  <a href="http://www.codeproject.com/KB/ajax/addingCssJsAjaxPartialPos.aspx" rel="nofollow">http://www.codeproject.com/KB/ajax/addingCssJsAjaxPartialPos.aspx</a>  </p>
  
  <p>Can anyone give any ideas why these don't work, or another way to do it?</p>
  
  <p><strong>EDIT:</strong> Additional information.<br>
  I am working with a very large legacy code base that has the forms and script manager in each page rather than in the master page. I would like to place the code into a class and use the following call to add the javascript effect.</p>
  
  <pre><code>ClientSideScripts.BackgroundColourFade(Page, ScriptManager, Control);
  </code></pre>
  
  <p>The reasons I want to include the script in the method call is</p>
  
  <ol>
  <li>Consumes of the method don't have to remember to include the script</li>
  <li>Changing the script used only requires a change in one place</li>
  <li>Only include the javascript when needed to keep the load time of the page down</li>
  </ol>