Solved

Get File Includes To Execute Correctly - I want to store a #include in a db field and have that include or code execute on an .asp page

Posted on 2006-06-10
4
235 Views
Last Modified: 2013-11-18
I am trying to build a content management system for an existing site, but so much of the content is in both massive amounts of includes or free form code.  I want/need to find a way to store code like the following:

      <tr>
            <td valign="top"><!--#include file="../crf/includes/sitemenu_black.asp"--></td>
      </tr>

 in a database field (MS Access) and have that stored field value execute as if I typed the code in myself.

The database does not have an issue with storing and string of code you give it, but I do not know how to get more than the HTML to execute correctly on a dynamic page...the #include does not work if I do something like <% Response.Write(objRSName("FieldName")%> or <%=objRSName("FieldName") %>, as the server attempts to write the <!--#include file="../crf/includes/sitemenu_black.asp"--> as text on the page but it renders the normal HTML code correctly.

This is extremely urgent.

Thanks,
0
Comment
Question by:endrec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
alorentz earned 500 total points
ID: 16876909
INCLUDE files are executed BEFORE any script...so you cannot do what you are trying to do...because the script happens after the include files are processed (hence why it is rendered as text.)

0
 
LVL 14

Expert Comment

by:huji
ID: 16876979
What you are trying to do is to call the includes when you need them. However, ASP doesn't support conditional includes. You can not add INCLUDES within IFs or FORs. Read here:
http://www.w3schools.com/asp/asp_incfiles.asp
I suggest you include all of the files, but modify them so the code appears inside SUBs. Than call the SUBs on those occasions. This way, all the code is included to all pages, but only the necessary parts are run.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 16877006
@huji - for the most part correct, as I mentioned.  However:

>>You can not add INCLUDES within IFs or FORs

This is not correct.  Includes can be included within IF or FOR, and are executed conditionally based on the IF or FOR.

For example:

<%

if request("test") = "1" then
%>
<!--#include file="/includes/test1.asp"-->
<%
else
%>
<!--#include file="/includes/test2.asp"-->
<%
end if
%>


This is perfectly fine.  While both includes are processed before the script, only one is actually included in the rendered result.  Same for using in a FOR loop.
0
 
LVL 14

Expert Comment

by:huji
ID: 16877180
@alorentz,
I meant the same thing indeed. The link I posted mentions an example of including within FOR. However, now that I read it, what I've written has a different meaning, which is totally wrong.
Thanks for your notification. It really worths a lot.
Huji
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP encrypted string and passing to a ASP Page 12 88
Session on Html 8 55
Read text on Table 7 49
SP inserts data with order number, then push the rest one order up 11 44
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question