Discussion Locked

Calling an ASP file from an HTML

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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?

6 replies

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

by rajaragavan k

The first two method I tried, For the first method. See I have to clarify you one things, that I am trying to put this asp in one of the free sites which supports ASP. Since our ISP doesn't provide us ASP support. So I want to put my asp on some free site and call it thru the HTML file in OUR ISP to display the page counter. But I am not sure How to call this ASP file from here. So If I have to use the First option, then I need asp support from our ISP. The second option I tried It doesn't work. The third option Is working fine, but It is not working with Netscape. So Go thru the code I posted above and give me any other solution.

by rajaragavan k

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

This discussion is closed to new replies.