Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Javascript Will Not Work on Page with Ajax Tab Control. Works on Page Without Tab Control.

$
0
0

Visual Studio 2012.

I have an ASPX page that has a masterpage behind it.  So the page has all its elements between an <asp:content> and </asp:content>.  I am using the Ajax control toolkit tab control on the page as well, moving stuff from other pages onto tab panels on the newly designed page.  The other pages have javascript, such as found below.  However, it seems that no matter where I place the scripts on the new page (whether just after the <asp:content>, just before the </asp:content>, or somewhere near the control that uses it inside the tab control, the system seems to never sees the script and cannot find the function.  Any ideas of what I can do to solve this issue? (I have added a comment after the script.  Please read)

Here is the script in question:

<script type="text/jscript">
        function calcTotalHours() {
            var TotalHours = document.getElementById('<%= EditForm.Findcontrol("TotalFacHoursTextBox").ClientId %>');
            var Hours = ['<%= EditForm.Findcontrol("SundayHoursTextBox").ClientId %>', '<%= EditForm.Findcontrol("MondayHoursTextBox").ClientId %>', '<%= EditForm.Findcontrol("TuesdayHoursTextBox").ClientId %>', '<%= EditForm.Findcontrol("WednesdayHoursTextBox").ClientId %>', '<%= EditForm.Findcontrol("ThursdayHoursTextBox").ClientId %>', '<%= EditForm.Findcontrol("FridayHoursTextBox").ClientId %>', '<%= EditForm.Findcontrol("SaturdayHoursTextBox").ClientId %>'];
            var total = 0;
            for (var i = 0; i <= 6; i++) {
                if (!isNaN(document.getElementById(Hours[i]).value) && document.getElementById(Hours[i]).value != "") {
                    total += eval(document.getElementById(Hours[i]).value);
                }
            }
            TotalHours.value = total;
        }</script>

When I place the script in a separate .js file and code the top of the page this way, it finds the function.  But the values of elements on the page are not found where Hours= is set above.
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <script type="text/javascript" src="ReportsScript.js"></script>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>