Javascript function not found when moved to external file
<p>I'm moderatley new to ASP.NET and very new to Javascript. I'm writing a ASP.NET UserControl. I had the following:</p>

<pre><code>&lt;head&gt;
&lt;title&gt;Select Asset &lt;/title&gt;
&lt;script src="../Scripts/jquery-1.9.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    function CheckThenCloseActiveToolTip(supplierID) {
        var radGrid = $find('ctl00_MainContent_SelectAssetGrid1_gridAssetList_ctl00');
        var selectedItems = radGrid.get_masterTableView().get_selectedItems()
        if (selectedItems == null || selectedItems.length == 0) return 'You must select an asset first';
        else {
            DoPartialPostBack('selectasset', selectedItems[0]._dataItem.Id);
            CloseActiveToolTip();
        }
    }

    function PopulateRooms(e) {
        var idx = e.selectedIndex;
        if (idx &gt; -1) {
            var dcId = JSON.stringify({ dataCenterId: e.options[idx].value });
            var pageUrl = '/WebService/AVWebService.asmx';

            $.ajax({
                url: pageUrl + '/GetRooms',
                type: 'post',
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                data: dcId,
                success: OnRoomsReceived,
                error: OnErrorCall
            });
        }
        else {
            var ddlRooms = document.getElementById('MainContent_SelectAssetGrid1_ddlRooms');
            ddlRooms.disabled = true;
            $('#ddlRooms').empty();
            ddlRooms.options[0] = new Option('', '-1');
            getAssets(0);
        }
    }

    function OnRoomsReceived(result) {
        var ddlRooms = document.getElementById('MainContent_SelectAssetGrid1_ddlRooms');
        if (result.d.length &gt; 0) {
            ddlRooms.disabled = false;
            $('#ddlRooms').empty();
            ddlRooms.options[0] = new Option('', '-1');
            for (var i = 0; i &lt; result.d.length; i++) {
                ddlRooms.options[i + 1] = new Option(result.d[i].Name, result.d[i].Id);
            }
        }

        if (result.d.length = 1)
            ddlRooms.selectedIndex = 1;

        getAssets(0);
    }

    function resetGridData() {
        getAssets(0);
    }

    function getAssets(startAt) {
        var cpId = document.getElementById('hfldCompanyId').value;
        var pageUrl = '/WebService/AVWebService.asmx';
        var tableView = $find('ctl00_MainContent_SelectAssetGrid1_gridAssetList').get_masterTableView();
        var ddldc = document.getElementById('MainContent_SelectAssetGrid1_ddlDataCenter');
        var dcIdx = ddldc.selectedIndex;
        var dcId = '';
        if (dcIdx &gt; -1)
            dcId = ddldc.options[dcIdx].value;

        var ddlrm = document.getElementById('MainContent_SelectAssetGrid1_ddlRooms');
        var rmIdx = ddlrm.selectedIndex;
        var rmId = '';
        if (rmIdx &gt; -1)
            rmId = ddlrm.options[rmIdx].value;

        var ddlStatuses = $find('ctl00_MainContent_SelectAssetGrid1_ddlStatuses';

        var rbgAssetClass = document.getElementById('MainContent_SelectAssetGrid1_rbgAssetClass');
        var ac = 0;
        var rbgInputs = rbgAssetClass.getElementsByTagName('input');
        for (var i = 0; i &lt; rbgInputs.length; i++) {
            if (rbgInputs[i].checked) {
                ac = i;
            }
        }

        var filters = [];
        var fbs = document.getElementsByClassName('rgFilterBox');
        for (var i = 0; i &lt; fbs.length; i++)
            if (fbs[i].value != '')
                filters[filters.length] = { field: fbs[i].alt, value: fbs[i].value };

        var params = JSON.stringify({ companyId: cpId,
            startIndex: startAt,
            maximumRows: tableView.get_pageSize(),
            filterExpressions: filters,
            dataCenterId: ddldc.options[ddldc.selectedIndex].value,
            roomId: rmId,
            Statuses: ddlStatuses._checkedIndices,
            assetClass: ac
        });

        $.ajax({
            url: pageUrl + '/GetSelectAssetData',
            type: 'post',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            data: params,
            success: updateGrid,
            error: OnErrorCall
        });
    }

    function updateGrid(result) {
        var tableView = $find('ctl00_MainContent_SelectAssetGrid1_gridAssetList').get_masterTableView();
        tableView.set_dataSource(result.d.gridData);
        tableView.dataBind();
        tableView.set_virtualItemCount(result.d.count);
    }

    function gridAssetList_Command(sender, args) {
        args.set_cancel(true);

        var pageSize = sender.get_masterTableView().get_pageSize();
        var currentPageIndex = sender.get_masterTableView().get_currentPageIndex();
        if (args.get_commandName() == 'Filter')
            currentPageIndex = 0;

        getAssets(pageSize * currentPageIndex);
    }

    function gridAssetList_Created(sender, args) {
        var fbtns = document.getElementsByClassName('rgFilter');
        for (var i = 0; i &lt; fbtns.length; i++)
            fbtns[i].style.visibility = 'hidden';

        var fbs = document.getElementsByClassName('rgFilterBox');
        for (var i = 0; i &lt; fbs.length; i++)
            fbs[i].onkeypress = applyFilter;
    }

    function applyFilter(args) {
        if (args.keyCode == 13)
            resetGridData();
    }

&lt;/script&gt;
</code></pre>

<p></p>

<p>This works most of the time, but if I'm loading the UserControl using Page.LoadControl(), it didn't always load the scripts correctly. For a couple of reasons (maybe poor ones) I thought I'd move the scripts to an external file.  </p>

<pre><code>&lt;script src="../Scripts/jquery-1.9.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="../Scripts/SelectAsset.js" type="text/javascript"&gt;&lt;/script&gt;
</code></pre>

<p>There's no additional code or setup in the .js file, just</p>

<pre><code>function CheckThenCloseActiveToolTip(supplierID) {
    var radGrid = $find('ctl00_MainContent_SelectAssetGrid1_gridAssetList_ctl00');
    var selectedItems = radGrid.get_masterTableView().get_selectedItems()
    if (selectedItems == null || selectedItems.length == 0) return 'You must select an asset first';

...
</code></pre>

<p>But now I get a RunTime error that "function gridAssetList_Command" us undefined. That function is bound to a grid's OnCommand event in the page .</p>

<p>When I examine the page in Firebug, it doesn't list my .js file in the list of script files.</p>

<p>I'm loading my scripts in the . I didn't change them, just moved them. What am I missing?</p>

<p>MORE INFO: </p>

<hr>

<p>It appears to be using different ClientIds when adding the functions to the controls. The error I'm getting drops be in a dynamic resource with the following:</p>

<pre><code>Sys.Application.add_init(function() {
$create(Telerik.Web.UI.RadGrid, {"ClientID":"ctl00_MainContent_ctl03_gridAssetList","ClientSettings": ...
</code></pre>

<p>I'm going to try changing referenes to getElementByClass()</p>
