| | |
Transfering javascript on content page
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Solved Threads: 0
Hi,
I have the following javascript:
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
I have the following javascript:
ASP.NET Syntax (Toggle Plain Text)
<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
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.
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.
![]() |
Similar Threads
- Can I use a template html page within another html page (Site Layout and Usability)
- Passing variable value from javascript to jsp page at run time (JSP)
- Print control to print the Content Page from a Master Page (ASP.NET)
- Calling a javascript function from C# (C#)
- Conflicting javascript slideshows on same page (JavaScript / DHTML / AJAX)
- how to call javabean from jsp page upon onChange event (JSP)
- Link to page in page (HTML and CSS)
- Yahoo! Unveils Content Relevance Technology (Search Engine Optimization)
- Getting data from ASP page A to ASP page B using javascript (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: How to pass parameter in Crystal report 9
- Next Thread: Add value manually into DropDownList, CheckBoxList and RadioButtonList.
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos application asp asp.net bc30451 bottomasp.net box browser button c# c#gridviewcolumn checkbox click commonfunctions confirmationcodegeneration content courier css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal forms formview gridview gudi homeedition hosting iframe iis javascript jquery listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security select silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xml xsl youareanotmemberofthedebuggerusers






