 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 5th, 2003, 08:35 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
update using Asp and jscript
hi all,
i need to update part of the page with the Information in the Application object every certain amount of time, all what i do that i use SetInterval(func,period) to synchronize the execution of this function, in this function i update the element in the page using InnerHtml attribute, this is a part of the code
function fnStartInterval(){
oInterval=window.setInterval("fnRecycle()",4000);
}
function fnRecycle(){
var htmlText
htmlText=""
htmlText="<%for i=Application("msgno")+1 to 10
response.write "<span STYLE='color:" & clrs((i mod 10)+1) & "'>" & application("msg" & i ) & "</span><br>"
next
for i=1 to Application("msgno")
response.write "<span STYLE='color:" & clrs((i mod 10)+1) & "'>" & application("msg" & i ) & "</span><br>"
next
%>";
//alert(htmlText);
update("writemsg",htmlText);
}
function update(id, html) {
document.all[id].innerHTML = html;
}
but i notice that the html text generated from ASP code is the same as it's reference the server once, all i need is to reference the server for each hit to the function called in SetInterval,
If Any one have Solution plz help
Ahmed Ali
Software Developer
__________________
Ahmed Ali
Senior Software Developer
|
|

November 6th, 2003, 12:25 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Take a look at your source HTML when this page is generated.
You'll notice that the values that you retrieved in ASP that you write out to the javascript block are static:
htmlText="<here is where the static text will be, instead of the asp code"
This is because the ASP is running on the server and only get's called once, when the page is first requested. You are having the client browser call fnRecycle at timed intervals, but the end result is always the same because it's only run at the server once.
The simplest way to do what you are trying is to set a auto refresh header on the page so the browser refreshes the page at timed intervals (and thus getting an updated version from the server).
If you only want to update a small part of the page and you need it to be that way, then you'll have to do something much more complicated.
One simple alternative (affected by what browsers you plan on supporting) is to use an iframe. This can contain a very simple page with just the contents that you want to have updated. That page can refresh to it's hearts delight, but the main page it lives in will stay the way it is without refreshing.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

November 6th, 2003, 06:27 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks peter for your detail solution,
i know some about iframe idea but i am asking i will then retrieve this part of asp code in request object, if you please give me sample code for this IFRAME Solution(how to use iframe).
Ahmed Ali
Software Developer
|
|

November 6th, 2003, 08:24 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
For either solution I suggested, you simply need to set the page to refresh after some time period. When it refreshes, it will update with the new information from the application object. You need to write out a meta refresh tag to the HTML so the browser will refresh the page.
The idea behind of the iframe is simply to minimize how much of the page you have to refresh. If you only really want to refresh a small piece, and you can use the iframe, then you just create a page with only the information that needs to be refreshed. You write this page out with refresh meta tag so it will refresh periodically in the iframe (versus the whole page in the browser refreshing).
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

November 6th, 2003, 08:48 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thx planoie, i use iframe and i periodically assign the src attribute for the iframe as ASP page but error is produced as the debugger stop on the first line of the asp page !!!
what i have to do????
fnRecycle is the periodic function set with setinterval
function fnRecycle(){
document.frames("updframe").src="MsgContent.asp"
}
this the file MsgContent.asp
<%
for i=Application("msgno")+1 to 10
response.write "<span STYLE='color:" & clrs((i mod 10)+1) & "'>" & application("msg" & i ) & "</span><br>"
next
for i=1 to Application("msgno")
response.write "<span STYLE='color:" & clrs((i mod 10)+1) & "'>" & application("msg" & i ) & "</span><br>"
next
%>
Ahmed Ali
Software Developer
|
|

November 7th, 2003, 10:34 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
What's the error you are getting?
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

November 9th, 2003, 12:06 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks planoie, i have found the error it was undeclard variable,
but i Know now how to use iframe,the problem remains i need to recieve data, where to get this returned data got from server, thats what i need help now ...like request("varname") recieved to iframe ???
how could i do that, .
Ahmed Ali
Software Developer
|
|

November 10th, 2003, 12:03 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
I'm not sure I understand what you are trying to do now. I thought all you wanted was to be able to update a section of the page at timed intervals. It seems you have gotten this part figured out.
Is there more? It sounds like you now want to do something with the actual output of the data in the IFrame. Do I understand your intention correctly?
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

November 11th, 2003, 12:11 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok to clear what i mean, i saw in the site http://www.theill.com/ a free code for asp chat and i saw that the asp page is working so smooth with out any refreshing the user could feel, so i was trying to understand this way,
if any could help.
Ahmed Ali
Software Developer
|
|

November 11th, 2003, 10:47 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Ok. I see what you are looking for now.
What is being used for ConquerChat is a whole different scenario. Well, not THAT different. That is all frames based. There are five different frames in that application, each pointing to a different page. They each run independently, although they do interact with each other to tell each other to refresh when something happens (like you enter a message).
All the data that shows up in each window (list of users, messages, etc) comes from objects that are stored in the Application object of ASP. It looks to me like the only frame-to-frame interaction is just one frame telling another to refresh.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|
 |