Adding a handler to an object that calls a global javascript function
<p>I'm not sure I worded the question the best way possible so I'll show my code example.</p>

<p>I have multiple pages that use the same javascript function. Instead of adding that function to every page, I added it to a .js and imported it in the site master. How can I add a handler to my objects that will call that function, the way I have it doesn't seem to be working.</p>

<p>Edit: I found the problem to be in </p>

<pre><code>document.getElementById('&lt;%= PostBackButton.ClientID %&gt;').click();
</code></pre>

<p>The javascript function does get called correctly and the page does have a PostBackButton asp button, but the getelement is returning null.</p>

<pre><code>//chart-ajaxDateSelection.js
function dateSelectionChanged(sender, args) {
  selectedDate = sender.get_selectedDate();

  document.getElementById('&lt;%= PostBackButton.ClientID %&gt;').click();
}

function getSlide()
{
  var i,x,y,ARRcookies=document.cookie.split(";");
  for (i=0;i&lt;ARRcookies.length;i++)
  {
    x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
    y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
    x=x.replace(/^\s+|\s+$/g,"");
    if (x=="slide")
    {
      return y;
    }
  }
}
</code></pre>

<p>My handler:</p>

<pre><code>&lt;asp:TextBox ID="OverviewChartStartDateTextBox" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;ajaxToolkit:CalendarExtender ID="OverviewChartStartCal" 
  OnClientDateSelectionChanged="dateSelectionChanged" runat="server" 
  TargetControlID="OverviewChartStartDateTextBox"&gt;
&lt;/ajaxToolkit:CalendarExtender&gt;
</code></pre>

<p>As you can see, I'm trying to call the dateSelectionChanged method when the selected date is changed on the ajax calendar.</p>
