Windows Server 2008 R2. IIS 7. Visual Studio 2012. .NET Framework 4.5. Ajax Control Toolkit (Dec 2013).
The following JavaScript worked on an aspx page prior to the addition of a Ajax tab control. This code is placed at the bottom of the aspx page just before the </asp:content> tag.
<script type="text/javascript">
try {
var e = document.getElementById("<%= ReportJurisdiction.ClientID %>");
alert(e.id);
e.options[e.selectedIndex].selected = true;
}
catch (Error) {
alert('error RJ');
}</script>When the page posted back, it ensured that a listbox named "ReportJurisdiction" did not scroll back to the top, but instead remained at the first selected item in the list. The listbox has now been placed in a Ajax tab panel. Now when the code runs (on page load), it does not find the control and the alert "error RJ" pops up. I guess I understand this, as perhaps on initial page load, the control has not been rendered yet. However, when the panel is updated, the code does not run again and the listbox scrolls back to the top.
WHERE should I place this code to ensure that it runs when the panel in which the listbox resides is updated/refreshed? Thanks for any help.