response.writing an include tag...not working?

D

darrel

I'm trying to load an include dynamically. So, I'm writing out the include
tag via a response.write:

response.write("<!--#include virtual='" & contentIncludeFile &"' -->")

however, that's writing out the include tag AFTER the page is processed,
obviously. Any suggestions for a way around this? Should I instead load the
contents of the include file as a string and then write that out?

-Darrel
 
S

Scott M.

Include directives are processed BEFORE any other server-side code and
because of this, you can't do what you are trying because the variable
"contentIncludeFile" hasn't been resolved yet.

This is not a .NET issue/question. It is how the server-side INCLUDE
directive is handled by the server.

Why not ditch "Response.Write" statements as well as INCLUDE directives and
start using .NET techniques such as labels (instead of response.write) and
User Controls (instead of SSI's)?
 
D

Darrel

Why not ditch "Response.Write" statements as well as INCLUDE directives
and start using .NET techniques such as labels (instead of response.write)
and User Controls (instead of SSI's)?

Because sometimes all you need is a response.write and an SSI. ;o)

I like .net, but really, I shouldn' have to use a UC just to include some
text.I find .net a huge improvement, but there's a lot of overkill at the
basic level.

In the end, I've got it working by opening the file, reading it into a
string, and sending the string back to the page. It works fine, but seems a
lot more complicated than a simple old include file ;o)

-Darrel
 
G

Guadala Harry

<<I shouldn' have to use a UC just to include some text.>>

Agreed, and you don't have to. Check out the Literal control. You just need
to set its Text property. The only thing that will show up on the rendered
page is the string you set for it (and in the location on the page in which
you have located the Literal control at design time).

-GH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top