Click to See Complete Forum and Search --> : can i put asp in a html page?


markandkelle
01-23-2008, 03:32 PM
Hi,
Is there anyway to include an ASP page in a HTML page without using a frame or iframe. I have an asp page as follows www.mydomain.co.uk/results.asp and this displays a selection of items for sale.
the length of the list varies from day to day, what I want to do is include this asp information in a div section of my html page so that it wil expand the section in relation to how many results are show on the asp page.

The result being that I will have only one scroll bar to use instead of one for main page and one for an iframe etc.

Hope this all makes sense and any suggestion will be greatly appreciated. If I can not put in HTML page, what is the other solution, can I use a script, ajax or something to grab the information?

Look forwrad to your reply.

Thanks

Mark

skyrider01
01-23-2008, 05:28 PM
You cant include an .asp file like that, but you can call it with ajax and show the result in your div

mangofreak
01-23-2008, 05:33 PM
As far as I understand you need a server that supports ASP first. Also the server should allow Includes. Then, there is a way to setup your server so you could show your ASP pages as HTML. I'm not sure if it will do exactly as you want, but here we go:

1. Open IIS and under the tab Home Directory click on Configuration
2. Under the tab App Mappings you see a list of extensions (.asp should be there too. pointing to a asp.dll)
3. Click the add button and fill in the .html extension.
4. Point it to the same directory as the .asp extension (...\asp.dll)
5. Click apply and ok and ok
6. restart you iis.

Hope it helps.

J.

markandkelle
01-24-2008, 02:36 AM
Hi thanks for the reply, skyrider any idea on where I can find information on calling it with Ajax?

skyrider01
01-24-2008, 02:55 AM
you can google for it, should be plenty of information about it, but to get you started you can use something like this, this will read in the content from the example.asp page, the generated content, and then show it inside the "nameofid" div tag.

haven't tested this, but should be close, but like I said, there will be plenty of help if you google for ajax


<script>
var content = document.getElementId("nameofid");
var xmlHttp;
xmlHttp=new XMLHttpRequest();
xmlHttp.onreadystatechange=function()
if(xmlHttp.readyState==4)
if (xmlHttp.status == 200){ content.innerHTML = xmlHttp.responseText; }
xmlHttp.open("get","/example.asp");
xmlHttp.send(null);
</script>
...
<div id="nameofid"></div>
...

markandkelle
01-24-2008, 05:08 AM
Hi I tried the code above and searching on google, but nothing seems to work? and other suggestions,

thanks

itHighway2007
01-24-2008, 02:54 PM
Skyrider code should work. Make sure:

- Your server has support for ASP
- Your path to .asp file is correct.

markandkelle
01-25-2008, 04:23 AM
Hi I have tried the code, the path is correct 100% but still no joy, I just get a blank page, no errors, nothing? any further ideas? will it make a difference if I am not using a windows server?

skyrider01
01-25-2008, 08:01 PM
The server you are using should not matter, .asp files generally dont work on non windows servers though, so make sure that you get some content from the results.asp file, just go to it in a browser and check.

if not, post an example that you are trying to make to work and I will have a look, cant promise anything though.

markandkelle
01-27-2008, 05:31 AM
Hi thanks for all your help so far, I am trying to include this in a div so that that it wil expand the section in relation to how many results are show on the asp page http://www.boats-search.com/searchmaidenmarine.asp?slim=pp238622&cit=true&sm=3&sm=3&fromLength=&toLength=&luom=126&fromYear=&toYear=&fromPrice=&toPrice=

I have tried this <script>
var content = document.getElementId("nameofid");
var xmlHttp;
xmlHttp=new XMLHttpRequest();
xmlHttp.onreadystatechange=function()
if(xmlHttp.readyState==4)
if (xmlHttp.status == 200){ content.innerHTML = xmlHttp.responseText; }
xmlHttp.open("get","/http://www.boats-search.com/searchmaidenmarine.asp?slim=pp238622&cit=true&sm=3&sm=3&fromLength=&toLength=&luom=126&fromYear=&toYear=&fromPrice=&toPrice=[/");
xmlHttp.send(null);
</script>
<div id="nameofid"></div>

skyrider01
01-27-2008, 06:03 PM
Ok, was some errors in that script, some spelling mistakes etc, I also reorganised the code a little to make it clearer to read.

However, if you are reading content from a different domain you will get security warnings

if you want to by pass that you might need to write some kind of "proxy" script that reads in the content to your domain eg. with a scheduled task and then use something like this script to read in that, then it would not complain about security.


<html>
<head>
<title>Test</title>
<script type="text/javascript">
var xmlHttp;
var content = document.getElementById("nameofid");

function loadPage(){
content = document.getElementById("nameofid")
xmlHttp=new XMLHttpRequest();
xmlHttp.onreadystatechange= getContent;
xmlHttp.open("get","http://www.boats-search.com/searchmaidenmarine.asp?slim=pp238622&cit=true&sm=3&sm=3&fromLength=&toLength=&luom=126&fromYear=&toY ear=&fromPrice=&toPrice=");
xmlHttp.send(null);}

function getContent(){
if(xmlHttp.readyState==4)
if (xmlHttp.status == 200){ content.innerHTML = xmlHttp.responseText; }
}
</script>
</head>
<body onload="loadPage();">
<div id="nameofid"></div>
</body>
</html>

markandkelle
01-28-2008, 02:49 AM
Hi thanks again for all your help so far, I really appreciate it, however I am still running into errors; this is my URL with the information you provided http://www.feeling-yachts.co.uk/test.htm
All I get is a blank page?
am I do something wrong that I am missing?

Thanks

skyrider01
01-28-2008, 04:12 PM
Was a missing ; after document.getElementById("nameofid") so should be
document.getElementById("nameofid"); that is what caused it not to work, since you had everything on one line in the source file

You can remove that line that caused the problem though, content = document.getElementById("nameofid"); the line that is inside the loadPage function

Also the url, have an extra space, toY ear should be toYear

If you install firebug addon in firefox, you will be able to see problems like this easier.

markandkelle
01-30-2008, 09:14 AM
hi so I have changed the code and get this error message from firebug 'Permission denied to call method XMLHttpRequest.open'

I have opened in IE7 and changed my permissions and now get this error message 'content is null or not an object ' from line 16 char 29.

any ideas?

thanks again

mark

skyrider01
01-30-2008, 04:08 PM
I have attached a file for you to try, just change the extension to .htm and it should work for you.

Like I said in one of my previous posts, you will get a security warning/error if you try and use this method to a page that is not on your domain, so you need to solve that in a different way.

Hope it will work this time :)

10363