Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a handler to an object that calls a global javascript function
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload