473,725 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Window.setInter val not working from asp.net

If The script below is exeuted from the onload="startit ()" in the body tag everything works fine but when I remove the onload and try to execute by using the attributes.add from within the Page_Load the window.setInter val will not execute - there is no message but the timer never takes off. I put an alert in the startit() and it did appear so the attributes.add is working ok.

Would appreciate any help

thanks



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attr ibutes.Add("onC lick", "startit()" )
End Sub
<SCRIPT>
function startit() {
window.setInter val("updateTime ()",1000);

}
var seconds=0;

function updateTime() {

// seconds++;
var timeNow = new Date();
var hours = timeNow.getHour s();
var minutes = timeNow.getMinu tes();
var seconds = timeNow.getSeco nds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getEle mentById("time" ).innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS_POSITIONING= "GridLayout " onload="startit ()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>
Nov 19 '05 #1
4 3256
I don't know what the <body> issue is, but in Page_Load try:

Page.RegisterSt artupScript("my startscript", "startit(); ")

-Brock
DevelopMentor
http://staff.develop.com/ballen
If The script below is exeuted from the onload="startit ()" in the body
tag everything works fine but when I remove the onload and try to
execute by using the attributes.add from within the Page Load the
window.setInter val will not execute - there is no message but the
timer never takes off. I put an alert in the startit() and it did
appear so the attributes.add is working ok.

Would appreciate any help

thanks

Private Sub Page Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attr ibutes.Add("onC lick", "startit()" )
End Sub
<SCRIPT>
function startit() {
window.setInter val("updateTime ()",1000);
}
var seconds=0;
function updateTime() {

// seconds++;
var timeNow = new Date();
var hours = timeNow.getHour s();
var minutes = timeNow.getMinu tes();
var seconds = timeNow.getSeco nds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getEle mentById("time" ).innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS POSITIONING="Gr idLayout" onload="startit ()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>


Nov 19 '05 #2
I tried your suggestion and put alerts into both functions and while the
first function which has the window.setInter val showed the alert the second
function being executed from the setInterval was never executed. No errors
appear.

I also put the code into my code behind but received the same results.

thanks
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:34******** **************@ msnews.microsof t.com...
I don't know what the <body> issue is, but in Page_Load try:

Page.RegisterSt artupScript("my startscript", "startit(); ")

-Brock
DevelopMentor
http://staff.develop.com/ballen
If The script below is exeuted from the onload="startit ()" in the body
tag everything works fine but when I remove the onload and try to
execute by using the attributes.add from within the Page Load the
window.setInter val will not execute - there is no message but the
timer never takes off. I put an alert in the startit() and it did
appear so the attributes.add is working ok.

Would appreciate any help

thanks

Private Sub Page Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attr ibutes.Add("onC lick", "startit()" )
End Sub
<SCRIPT>
function startit() {
window.setInter val("updateTime ()",1000);
}
var seconds=0;
function updateTime() {

// seconds++;
var timeNow = new Date();
var hours = timeNow.getHour s();
var minutes = timeNow.getMinu tes();
var seconds = timeNow.getSeco nds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getEle mentById("time" ).innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS POSITIONING="Gr idLayout" onload="startit ()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>


Nov 19 '05 #3
Yeah, sorry. I gave you bad javascript for RegisterStartup Script:

<script runat="server">
private void Page_Load(objec t sender, System.EventArg s e)
{
this.RegisterSt artupScript("My Init", "<script>DoInit ();</script>");
}
</script>
<script>
<!--
function DoInit()
{
window.setInter val('foo()', 500);
}
function foo()
{
document.getEle mentById('myLab el').innerHTML += 'x';
}
-->
</script>

-Brock
DevelopMentor
http://staff.develop.com/ballen
I tried your suggestion and put alerts into both functions and while
the first function which has the window.setInter val showed the alert
the second function being executed from the setInterval was never
executed. No errors appear.

I also put the code into my code behind but received the same results.

thanks
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:34******** **************@ msnews.microsof t.com...
I don't know what the <body> issue is, but in Page_Load try:

Page.RegisterSt artupScript("my startscript", "startit(); ")

-Brock
DevelopMentor
http://staff.develop.com/ballen
If The script below is exeuted from the onload="startit ()" in the
body tag everything works fine but when I remove the onload and try
to execute by using the attributes.add from within the Page Load the
window.setInter val will not execute - there is no message but the
timer never takes off. I put an alert in the startit() and it did
appear so the attributes.add is working ok.

Would appreciate any help

thanks

Private Sub Page Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attr ibutes.Add("onC lick", "startit()" )
End Sub
<SCRIPT>
function startit() {
window.setInter val("updateTime ()",1000);
}
var seconds=0;
function updateTime() {
// seconds++;
var timeNow = new Date();
var hours = timeNow.getHour s();
var minutes = timeNow.getMinu tes();
var seconds = timeNow.getSeco nds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getEle mentById("time" ).innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS POSITIONING="Gr idLayout" onload="startit ()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>


Nov 19 '05 #4
That was the answer. One thing to add. I put the RegisterStartup Script in
the button click event so it would not start automatically but wait until I
hit the button.

Thanks a lot. This really helps with understanding asp.net and javascript
relationships and using client side programming.

"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:34******** **************@ msnews.microsof t.com...
Yeah, sorry. I gave you bad javascript for RegisterStartup Script:

<script runat="server">
private void Page_Load(objec t sender, System.EventArg s e)
{
this.RegisterSt artupScript("My Init", "<script>DoInit ();</script>");
}
</script>
<script>
<!--
function DoInit()
{
window.setInter val('foo()', 500);
}
function foo()
{
document.getEle mentById('myLab el').innerHTML += 'x';
}
-->
</script>

-Brock
DevelopMentor
http://staff.develop.com/ballen
I tried your suggestion and put alerts into both functions and while
the first function which has the window.setInter val showed the alert
the second function being executed from the setInterval was never
executed. No errors appear.

I also put the code into my code behind but received the same results.

thanks
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:34******** **************@ msnews.microsof t.com...
I don't know what the <body> issue is, but in Page_Load try:

Page.RegisterSt artupScript("my startscript", "startit(); ")

-Brock
DevelopMentor
http://staff.develop.com/ballen
If The script below is exeuted from the onload="startit ()" in the
body tag everything works fine but when I remove the onload and try
to execute by using the attributes.add from within the Page Load the
window.setInter val will not execute - there is no message but the
timer never takes off. I put an alert in the startit() and it did
appear so the attributes.add is working ok.

Would appreciate any help

thanks

Private Sub Page Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attr ibutes.Add("onC lick", "startit()" )
End Sub
<SCRIPT>
function startit() {
window.setInter val("updateTime ()",1000);
}
var seconds=0;
function updateTime() {
// seconds++;
var timeNow = new Date();
var hours = timeNow.getHour s();
var minutes = timeNow.getMinu tes();
var seconds = timeNow.getSeco nds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getEle mentById("time" ).innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS POSITIONING="Gr idLayout" onload="startit ()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7791
by: Richard A. DeVenezia | last post by:
At line this.timerId = setInterval (function(){this.step()}, 100) I get error dialog Error:Object doesn't support this property or method. If I change it to this.timerId = setInterval (function(){this==window}, 100) I see true, the sad fact that 'this' is window and not an anim. What are some proper ways ? I would like to avoid
1
8883
by: John | last post by:
Michael Winter <M.Winter@blueyonder.co.invalid> wrote in message news:<opr3wd8yvj5vklcq@news-text.blueyonder.co.uk>... > On 24 Feb 2004 14:13:47 -0800, John <johnmark@fastermail.com> wrote: > > > I would like to use setTimeout and window.open methods to pop up > > window every 5 minutes. I can only manage to make the window to pop up > > only twice. > > > > function openWindow() { > > window.open("popupwindow.htm",...
5
7536
by: spam_me_ not | last post by:
I already understand that one cannot disable a browser's forward and back functions. This is a situation where I have code working in Mozilla V1.6 and would like something similar for Opera and IE. I link within a page and display individual divisions of that page, manipulating their visibility and display styles with an onClick function. As long as I explicitly click a link to progress, it works with browsers I've tried.
3
4420
by: Eli | last post by:
Hello all, I have just added a small piece of JavaScript code to a basic HTML page of mine. At the end of the page (after the closing </HTML>) I added: <SCRIPT LANGUAGE="JavaScript"> window.setInterval ("myFunc()", 1000); </SCRIPT> The function myFunc is as easy as you might expect, to update a text
2
9926
by: abs | last post by:
How to detect that user started to scroll the page ? Separately vertical and horizontal scroll. Is it possible ? Regards, ABS
6
15224
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I am doing wrong? Your help will be much appreciated. Thanks
3
5810
by: shawn | last post by:
Hi All Was trying to get this bit of code working (simplified of course) for (i=0;i<uuid_num;i++) { window.setInterval(InitMap(uuidValues), timePeriod); } Where uuid_num, uuidValues, timePeriod are defined above, along with function InitMap.
3
2263
by: Josh Pencheon | last post by:
Hello. My name is Josh, from the UK. I'm 16, and having a spot of bother with some javascript I've been working on over the past few days, that gives a sliding menu. <html> <head> <script type="text/javascript"> <!-- menustatus = 'down'; bouncecount = 10;
0
8872
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8747
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9392
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8069
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5997
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4773
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2619
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2150
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.