Click to See Complete Forum and Search --> : SSI equivalent in ASP?
hey,
What I need to do is have a link to an external file in the second column of every page of my site, as the content of this column needs to be updated constantly, controlled and generated by a separate program. Therefore this needs to be a separate document (not frames due to aesthetic reasons etc). I have been advised that an ASP equivalent of a SSI would be ideal (my host doesnt support SSI or PHP) - does anyone know about this?? or have any other ideas - am totally stuck on this one
thanks loads
cate
gil davis
11-05-2003, 01:15 PM
<!--#include file="filename.ext"-->
There is also an "#include virtual=" but I don't know all the particulars. Here is a good reference:
http://msdn.microsoft.com/library/en-us/iisref/htm/ref_vbom_.asp
that seems really simple...? i just add that code in somewhere, as a comment (?) and it will retrieve and display the file, in the second column?
gil davis
11-06-2003, 02:12 PM
As long as it is an ASP file and you do it on an ASP server, yes.
i see - so the file im retrieving has to be an ASP file? (sorry, getting my wires crossed!)
gil davis
11-06-2003, 03:58 PM
Yes. As opposed to an HTML or PL or CGI file.
PeOfEo
11-06-2003, 04:56 PM
The reaon an html file or something would not work is because it is a client side file and well the server never parses it and would never see the include code so therefore it would not do squat. The cgi stuff is sort of obvious though
right, so does that mean I should code my whole site in ASP as each page will need this include comment...?
PeOfEo
11-06-2003, 05:18 PM
There are alternative methods. Would an iframe work, or maybe adapting an object tag to suit your needs. But to use an include, yes your page will need to be a .asp, also make sure you do not create duplicate <html> etc in the process, view yor server outputed source code.
eshk, this is all very confusing. I had thought of Iframes but for aesthetic reasons decided against them, because of scrolling bars messing up the design. Would you have a look at the site and see what you think?
http://www.heneage.com
The section which needs constant updating is the vertical list of books in the far right column. What exactly is an object tag?
PeOfEo
11-06-2003, 06:03 PM
well an iframe is an object, so is an embeded video, applets, flash etc. Things of that nature are objects. But you can also have text and html put into one. I posted an object tag like this a while back in the html forum, the only problem is that only ie handled it. With the next version of Ie, it might not work because it is supposed to read objects more like ns or mozilla reads them. But you could try an include, you will not need to do any hard core asp scripting, just on the page you are includeing, leave off all of the asp import stuff and make sure you leave of the <html><head><body> tags, put all your link code in the head of the main page. Basically you will be importing an html file but this html file would not need to and actually could not adhear to standards or even be laid out like a normal html file but since a browser does not actually read this file and its code is just thrown into your page that should not be a problem. Do you follow what I am saying?
not really! am rather tired so maybe its not going in, will reread it in the morning and try and make sense of it then - but by an include do you mean a SSI? as my host wont support them unfortunately. I get what you mean by an object i think. Need a solution that will be compatible with all browsers as this is something my client is very keen on. Not following the rest of your message though I'm afraid!
PeOfEo
11-06-2003, 07:37 PM
ssi, and an include are not neccessarily the same
<!--#include file="filename.ext"-->
is an include in asp and it is not ssi. ssi implies that you are including an external file without actually using a server side language but the server is tacking it into a client side file when it uploads it. Let me whip you up an example. It will be in asp.net, but doing this in asp.net and asp are basically identical that include comment up there is the same in both.
thankyou, that would be great:)
PeOfEo
11-06-2003, 07:48 PM
Ok here is the html part I used for my page, this would be your main page
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div style="width:500px; height:500px; left:50px; top:20px; position:absolute;"><!-- #Include virtual="theotherfile.html" --></div>
</body>
</html>
Ok now here is the file being included. It is theotherfile.html, but you will notice it is not a full html document, thats what I was trying to show you
<a href="link">link1</a><br>
<a href="link">link2</a><br>
<a href="link">link3</a><br>
<a href="link">link4</a><br>
thats it, thats theotherfile.html, Do not use <head> or <body> tags your css should be in the head section of the main page also. Lets look at the server output for this when its all done
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div style="width:500px; height:500px; margin-left:50%; margine-right:50%; position:absolute;"><a href="link">link1</a><br>
<a href="link">link2</a><br>
<a href="link">link3</a><br>
<a href="link">link4</a><br>
</div>
</body>
</html>
See how the links just as they were wound up where the comment was? Thats basically all there is to it. To see it in action go to
http://knights.europe.webmatrixhosting.net/themainfile.aspx
You will notice the .aspx, like I said before I did it in asp.net because I do not use asp classic. I could host it in asp off of my computer which runs iis but my comp is not up 24/7 and my host is asp.net only. But the syntax, the include part, is exactly the same in both. All you need to add in are those asp page headers like the language and everything else.
Btw: you could actually just use a text file and include that it does not have the be html format since its contents are being incerted into an html file. But you will be using html in the file, like the link code etc.
my god, i get it! how cool! okay, will put it into practise over the next couple of days - is it cool to come back to you with any queries?
PeOfEo
11-06-2003, 08:31 PM
Sure, Ill try to answer them the best I can. But like I said several times already I do not use asp classic, I use asp.net and though they may act similarly sometimes, they are quite different. I mean asp.net was based on asp, but asp.net is more evolved and refined. I just went straight to learning asp.net and never learned asp so if its asp syntax etc I might not be the best person to come to.
PeOfEo
11-06-2003, 09:57 PM
Hey once you have your includes down for your layout be sure post a link in or send me a pm because I want to see it in action :P
ok so have only just got round to putting this include stuff into action (so busy)! but quick question to clarify - the files that hold the include comment need to be asp files, but it doesnt matter what the file to be included is (html or text or something)?
PeOfEo
11-17-2003, 01:02 PM
that is correct.
ok, its up there, see what you think! thanks for your help:)
PeOfEo
11-17-2003, 08:55 PM
well I cant tell where the include was exactly but it is working obviosuly. I am using includes in asp.net so that I only have 3 lines of code in my pages w/ out the content
<%@ Page Language="VB" Debug="true" validateRequest="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<head>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>WFRP - Free Radio Paxon</title>
<script type="text/javascript" src="ddmenu.js"></script>
<style type="text/css" media="screen">@import "layout.css";</style>
</head>
<body>
<!-- Center Content -->
<div id="contentshell">
<div id="content">You are looking at the future layout for the free radio paxon website! What do you think eh? <a href="http://validator.w3.org/check/referer">Is this layout valid?</a><br>
</div>
</div>
<!-- #Include virtual="layout.aspx" -->
</body>
</html>
OK its a little more then 3 but look at the full source code at
http://paxonradio.vze.com its a considerable amount more :D