User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,459 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2796 | Replies: 1
Reply
Join Date: Aug 2007
Posts: 3
Reputation: piote is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
piote piote is offline Offline
Newbie Poster

Transfering javascript on content page

  #1  
Oct 17th, 2007
Hi,

I have the following javascript:


<script language="javascript" type="text/javascript">

// Global variables.
var numSeconds;
var timerId = null;
var timerInterval = 1000;
var numUpdates = 0;

// Handle OnLoad event.
window.onload = Window_OnLoad;

function Window_OnLoad()
{      
    StartProcess();
}

// Starts the process for updating the Map.
function StartProcess()
{
    // 200 x 3 seconds = 600 seconds = 10 minutes demo.
    if ( numUpdates < 72 )
    {
        // Duration between actual updates to the map in seconds.
        numSeconds = 3;
        UpdateMap();
        numUpdates++;
    }
}
                   
// Continues the process of updating the Map.
function UpdateMap()
{               
    if ( numSeconds == 0 )
    {
        // Clears the timer.
        clearTimeout(timerId);
        
        // Update the Map control.
        var mapControl = document.getElementById("MapControl1");
        mapControl.doCallback("IncrementSales", "");
    
        // Restart the process.
        StartProcess();
    }
    else
    {
        // Decrease the value for seconds.
        numSeconds = numSeconds - 1;
        
        // Continue the delayed process.
        timerId = self.setTimeout("UpdateMap()", timerInterval);
    }
}
</script>



It works fine, when used on a standalone page, but when I am using masterpage and contentpages and I paste it into my content page (between <asp:content> and </asp:content> tags) it does not work. I'm a newbie at javascripts and I assume that there is something simple to correct. Could you please help me to make this script work under my content page?



Regards,

Piote
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,166
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 59
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Transfering javascript on content page

  #2  
Oct 17th, 2007
This is probably to do with how the javascript is rendered (somewhere in the middle) in the completed page that goes to the browser.

I would put the javascript in a .js file. Then in the page_load event of the content page you can get a reference to the master (can't recall syntax off the top of my head but it's something like: Page.Master) then attach a script block using Master.ClientRegisterScriptBlock where the Src property is the relative path to the .js file.

Sorry I can't give exact code this very moment, If I get a chance I will post it.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 5:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC