Calling an ASP file from an HTML
Hi,
I have an counter program written in ASP working perfectly. But I want to know how to call this inside a HTML page to put a page counter for this page.
Can anyone help me?
Desktop
Hi,
I have an counter program written in ASP working perfectly. But I want to know how to call this inside a HTML page to put a page counter for this page.
Can anyone help me?
by jay eckles
There are at least three things that you can do:
1. Put the ASP code directly in the HTML file:
Whatever content you have...
<% 'counter code here %>
Some more content if you like...
2. Include the ASP file using an SSI (server-side include):
Whatever content you have...
Some more content if you like...
3. Include the ASP file using an IFRAME:
Whatever content you have...
Some more content if you like...
Good luck.
Jay Eckles
www.jayeckles.com
Following is the asp code i have. The file name is count.asp
<%Dim fsoObject
Dim tsObject
Dim filObject
Dim lngVisitorNumber
Dim intDisplayDigitsLoopCount
On Error Resume Next
lngVisitorNumber = 0
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
Set filObject = fsoObject.GetFile(Server.MapPath("counter.txt"))
Set tsObject = filObject.OpenAsTextStream
lngVisitorNumber = CLng(tsObject.ReadAll)
If Session("lngSessionVisitorNum") = "" Then
lngVisitorNumber = lngVisitorNumber + 1
Session("lngSessionVisitorNum") = lngVisitorNumber
Else
Session("lngSessionVisitorNum") = lngVisitorNumber
End if
Set tsObject = fsoObject.CreateTextFile((Server.MapPath("counter.txt")), True)
tsObject.Write CStr(lngVisitorNumber)
Set fsoObject = Nothing
Set tsObject = Nothing
Set filObject = Nothing
Response.Write " You Are Visitor Number
"
For intDisplayDigitsLoopCount = 1 to Len(lngVisitorNumber)
Response.Write ""
Next
'Response.Write(lngVisitorNumber)%>
The digits directory exists and with all the digits. And following is the Html file,
And I want to display the counter in the Html page. I have a personal web server running on my machine. But still I am not getting my counter displayed. Can you plllllllllllllllease help me.
by jay eckles
The HTML you have on your machine running PWS works because PWS supports SSI, which apparently your ISP doesn't.
Since it also doesn't support ASP, that means that the only way to include your ASP file other than IFRAME is OBJECT, which may or may not work depending on the browser. I would try wrapping an OBJECT in an IFRAME to get the best results. However, neither of these will work with older browsers. The only other thing you could do is use old-fashioned FRAMES - here's a sample frameset:
This will put your counter in a frame that takes up the top 20% of the browser's screen. You could of course put itat the bottom or make a more complex frameset. This will work with virtually all browsers.
You should have indicated in your original post that the ASP is hosted on a different server than your HTML file; that makes a big difference. Beyond what I've suggested here, I don't know of a way to do what you want.
Good luck.
Jay Eckles
www.jayeckles.com
Thanks for your help.
We achieved the displaying the counter.
This discussion is closed to new replies.
Sort by Trending