#include virtual

  • Thread starter Thread starter Alex
  • Start date Start date
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.
 
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.
 
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
 
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.
 
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.
 
Back
Top