Including an include directive at run-time

C

chopper

Please excuse the long post but I can't think of shorter way of
explaining the issue.

Please could someone advise on the following:
I'm writing preview functionality for a CMS written in ASP.
Currently, when a page is published (physical file created in the
website) it contains include directives to pull in commonly used bits of
HTML and ASP such as the header and footer of pages.

In the preview functionality I want to be able to have asp deliver the
content directly to the browser rather than have to physically publish
the files first. In other words, rather than merging a template with the
content stored in the database and creating the file, I want to be able
to store all of the page source in a variable and response.write it to
the browser.

The problem I'm having is that when the page is written to the browser
it's putting the actual include directive and not the content of the
included file into the page. I've got round this for the html includes
by reading the actual file content into a variable and merging that with
the content. The issue is with the asp pages that need to be included as
the result is a page that includes the actual asp and not the content
that should be generated by the asp.

For example, when a page is published on the site, the template might
include the following code "<!--#include file="something.asp"-->. So
when the published page is opened in the browser it 'includes' the
rendered result of something.asp at runtime.
When I store the merged template in a variable and output it, the
'rendered' page source includes the actual include directive
"<!--#include file="something.asp"-->"
If I use an FSO to pull something.asp in, I get the server-side asp in
the source of the rendered page and therefore tries to run it as
client-side vbscript which will not work.

I guess what I somehow need to do is pull in the content that is being
generated by the asp page (that was previously 'included') and display
the rendered HTML. Can anyone tell me if this is possible and, if so,
how it's done?
 
C

chopper

Aaron said:

Thanks for your reply Aaron.
I tried using server.execute but it's actually executing in the code
whilst I'm building up the the variable that contains the page source I
want to send to the browser. As a result, it's outputting the executed
file first, the outputting the rest of the code I built up in the variable.

The only way it would work in my case is if I could somehow return to a
variable the result of the server.execute (or something similar). Is
this possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top