devxlogo

Dynamic Includes

Question:
How can I do a dynamic include, such as:

However, I think I know why this doesn’t work– because includes are tossed in before it goes to the parser (asp.dll). But if that’s the case, why is it? I seem to have tried every possible combination trying to get this to work, to no avail.

Answer:
You are right: it can’t be done. But there is a workaround, if you can live with it. Simply use a large Select Case statement:
<%Select Case varfilename Case "value1"%><% Case "value2"%><%
… and so on …
%><%End Select%>
Be very careful about placing the <% and %> tags, though.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.