| Welcome to Webforumz.com. |
|
Jan 26th, 2008, 20:47
|
#1 (permalink)
|
|
Junior Member
Join Date: Dec 2007
Location: UK
Posts: 25
|
how can i use my javascript code with my asp.net page
hi,
i have written the following javascript code. however i am writing my web application using visual web developer 2008 express edition, and i am finding it hard to incorporate it into my asp.net page. can i use javascript in asp.net page? does anybody have any suggestions as to how i can do this. the point of my code is to have a series of text appear on the web page in a sequence on after the other. please can someone help me, any suggestions will be appreciated.
<html>
<head>
<script type="text/javascript">
function timedText() {
var t1=setTimeout("document.getElementById('displayDiv ').innerHTML+='2 seconds!<br>'",2000);
var t2=setTimeout("document.getElementById('displayDiv ').innerHTML+='4 seconds!<br>'",4000);
var t3=setTimeout("document.getElementById('displayDiv ').innerHTML+='6 seconds!'",6000);
}
</script>
</head>
<body>
<form>
<input type="button" value="Display timed text!" onClick="timedText()">
<div id="displayDiv">
</div>
<p>Click on the button above. It will tell you when two, four, and six seconds have passed.</p>
</body>
</html>
|
|
|
Mar 11th, 2008, 20:01
|
#2 (permalink)
|
|
Junior Member
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
|
Re: how can i use my javascript code with my asp.net page
try onclick and not onClick...
then, there's an error in your javascript: setTimeout takes a function on the first argument, not a string... so just define a method
function _2seconds() {
document.getElementById('displayDiv ').innerHTML+='2 seconds!<br>';
}
and now, use the following line:
var t1=setTimeout(_2seconds, 2000);
I think that's much better.
|
|
|
Mar 11th, 2008, 20:02
|
#3 (permalink)
|
|
Junior Member
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
|
Re: how can i use my javascript code with my asp.net page
And, of course, do the same for 4 and 6 seconds...
|
|
|
Mar 11th, 2008, 20:03
|
#4 (permalink)
|
|
Junior Member
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
|
Re: how can i use my javascript code with my asp.net page
If you use a JavaScript framework, like prototype, you can bind data on methods you give as argument...
example:
var t1=setTimeout(myMethod.bind(2), 2000);
|
|
|
Mar 14th, 2008, 06:11
|
#5 (permalink)
|
|
Junior Member
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
|
Re: how can i use my javascript code with my asp.net page
did it help you ?
|
|
|
Mar 14th, 2008, 06:17
|
#6 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: how can i use my javascript code with my asp.net page
LOL, his last post was on last January and you still talking to him 
He might be long gone or solved his problem in other place since we took 2 month to reply to his problem
I think he solved them already mate!
Now we can move on!
__________________
|
|
|
Mar 14th, 2008, 17:53
|
#7 (permalink)
|
|
Junior Member
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
|
Re: how can i use my javascript code with my asp.net page
ok, I move on 
|
|
|
Mar 14th, 2008, 17:57
|
#8 (permalink)
|
|
Junior Member
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
|
Re: how can i use my javascript code with my asp.net page
but it can help other buddies...
thanks indeed, I didn't see the post date
|
|
|
Mar 17th, 2008, 02:57
|
#9 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: how can i use my javascript code with my asp.net page
I'll help you look for this skat guy..
Great solution by the way 
__________________
|
|
|
| Thread Tools |
|
|
| Rate This Thread |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|