• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 904
  • 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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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