Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 900
  • Last Modified:

ASP - Dynamically include HTML page in ASP page

I have an ASP page. In it I have a DIV and in that I want to include an Include file which is only HTML 'includeNNNN.inc' - (NNNN is obtained from a database according to a Query String. That part I can do and will be in this <% =rsData.Fields.Item("pagename.inc").Value %> )

I know I can't have a dynamic include file because the Include is processed before the <% %> script.

The file I want to include is an HTML file. ie. no script to run on it. (Each of these have an article relating to the topic NNNN. can be up to 1,000 words)

Can someone suggest any ideas please?

My present knowledge is classic ASP. If PHP or ASP.NET have a solution I'm listening.
Thanks!
0
hindersaliva
Asked:
hindersaliva
  • 2
  • 2
  • 2
1 Solution
 
GaryCommented:
How about
Server.Execute(filename & ".html")
0
 
hindersalivaAuthor Commented:
Gary!
That simple. It worked!
Thanks.

A point to make: My last ASP hard core was until 2002 working with ASP2. just now I read a lot of stuff dated pre-ASP3.0 (that's now out of date) tearing my hair out.

I should have asked here first but wanted to put in some research before I did. Wasted 1.5 hours!
Thanks Gary!
0
 
GaryCommented:
;o)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Dave BaldwinFixer of ProblemsCommented:
Well, it took too long but here's my version that works off the query string.  You'd have to make up your own 'inc' files.
<%@ LANGUAGE = VBScript %>
<%  Option Explicit		%>
<% 
dim fs,fnum,filnam,t,x
fnum=Request.QueryString("fnum")
 %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>ASP Read Text</title>
</head>
<body>
<h1>ASP Read Text</h1>
<h3>Test Links</h3>
<a href="ASPreadtext.asp?fnum=1">ASPreadtext.asp?fnum=1</a><br>
<a href="ASPreadtext.asp?fnum=2">ASPreadtext.asp?fnum=2</a><br>
<% 
If fnum<>"" Then
	filnam = "include" & fnum & ".inc"
	set fs=Server.CreateObject("Scripting.FileSystemObject")
	set t=fs.OpenTextFile(Server.MapPath(filnam), 1)
	x=t.Read(2047)
	t.close
	Response.Write(x)
	'Response.Write(filnam)
End If
 %>
</body>
</html>

Open in new window

0
 
hindersalivaAuthor Commented:
Dave,
I have already accepted Gary's solution. It works.

Has Scripting.FileSystemObject have an advantage over Server.Execute?
Thanks for doing it.
0
 
Dave BaldwinFixer of ProblemsCommented:
I know but I finished it so I posted it.
Has Scripting.FileSystemObject have an advantage over Server.Execute?
I have no idea.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now