Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2003, 03:15 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use a Variable for an Include Statement

Hi there,

I'm trying to create a website that is completely database driven (Access) using VBScript. I want to use a variable for my include file statement, but when I pull the text from the database:
(data stored in Access)

In my default file, I use the variable:
<% =txt_header %>

all that ends up on the screen is the text from the database (as shown above) versus the code from the header.asp include file (i.e. logo, etc.) It doesn't seem to process the include file directive, only the request from the database. There must be a step I'm missing, but I'm not sure what it is.

I also use a different include file (tblpages.asp) in the default page to extract the database information into variables before I use the variable.

Does this make sense to anybody, and would somebody know how to work around this?

Sample code of my default.asp page:

 (extract variables)

<html>
<head>
    <title><%= txt_Title %></title>
    <meta name=Keywords content="<%= txt_Keywords %>">
    <meta name=Description content="<%= mem_Description %>">
    <link rel="stylesheet" href="<%= txt_Stylesheet %>" type="text/css">
</head>
<body>
<table width="760" height="100%" border=0 cellspacing=3 cellpadding=3>

  <tr valign="top">


        <td colspan=2>
            <% =txt_Header %>(all other variables work, except this one)
        </td>
  </tr>



Thanks!

Paula


 
Old August 25th, 2003, 03:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Paula,

Dynamic includes won't work like that. ASP pages are included before the page is executed, so the variables don't have a value yet.

Check out this article for a more thorough explanation and some work arounds.

HtH


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 25th, 2003, 03:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The include statements are evaluated and included before any ASP code is executed. Unfortunately, you cannot dynamically generate include file statements

Chris





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using variable as fieldname in SELECT statement elygp SQL Server 2000 3 April 26th, 2007 10:14 AM
Storing an include in a variable trufla Beginning PHP 1 May 21st, 2006 10:52 PM
Passing a Global Variable Into a SQL Statement lwendt33 SQL Server DTS 1 February 2nd, 2005 05:40 PM
HelpX_x; How do I include a variable file in aspx? CSharp1314 Classic ASP Basics 16 May 5th, 2004 06:15 PM
include file in if statement isheikh BOOK: Beginning ASP 3.0 2 April 11th, 2004 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.