#include virtual

A

Alex

Hi,

I have noticed that in an aspx page

<!--#include virtual="Home.htm"--> acts the same as <!--#include
File="Home.htm"-->

when I am NOT in the root diectory of the site (I am aware that they will
reference the same file if in the root dir)

for example I have a directory on my site called "Admin" immediatly
subordinate to the root.

using inside default.aspx in "Admin" have the line
<!--#include virtual="Admin/AdminHome.htm"-->
This gives me the error
Could not find a part of the path
"c:\inetpub\wwwroot\Emailer1\Admin\Admin\AdminHome.htm". (notice the
duplicate "Admin" dir )

However the following works

<!--#include virtual="AdminHome.htm"--> and feel it should not becaues in
classic asp virtual references the root of the website.

cheers

Alex.
 
K

Kevin Spencer

Okay, first, even in Classic ASP, when you use "#include virtual..." you
need to put a slash in front of your path (<!--#include
virtual="/Admin/AdminHome.htm"-->). That will make your include work.
However, you should be aware that server-side includes are not
object-oriented, and are included merely for backwards-compatibility. You
should be using User Controls instead of included files.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
G

Guest

The problem with User Controls is that they do not have
any design time capabilities. Therefore, sometimes I use
includes so I can see what I am doing during design.

jay
 
A

Alex

Hi Kevin,

I entirly agree about the user control argumnets, and thanks for pointing
out the missing "/"

Bacically I am using a #include to include a static html page in the default
home page of my application. The application will be given out to a fair few
people and installed on there server. The deafault home page will need to be
customised for each company so I though #including a .htm page in side my
default.aspx whould be the way to go.

cheers

Alex.
 
K

Kevin Spencer

A User Control can certainly be static HTML.

In any case, glad I could help in some way. :)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 

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

Top