Master Pages and content pages in subfolder

Master Pages and content pages in subfolder

Post by vikram » Sun, 15 Oct 2006 01:43:05


Hi,

I am still new to ASP.NET 2.0 and trying to develope something using
Master pages.

My problem is:
I have a master page that contains Logo image and a navigation menu at
the top of the page so that this will be displayed on all the content
pages automatically.
This works fine for the content pages that are stored in the same
folder as that of Master page.

But I have a content page that is stored in a sub-folder (not in the
same folder as that of master page). Because of this, the contents
inherited from the master page (images/hyperlinks on master page) are
not rendered on content page. The reason being their relative paths
become invalid as my content page is inside a sub-folder.

How to resolve this issue? Do I have to mention the path for images
(and other relative paths) on master page using some different
technique (using ~ or something of that sort?)


thanks.
 
 
 

Master Pages and content pages in subfolder

Post by Mark Ra » Sun, 15 Oct 2006 02:07:29


Do yourself a *HUGE* favour and design your web app so that everything is at
the same level off the root, e.g.

<root>
\bin
\css
<stylesheets go here>
\folder 1
<content goes here>
\folder 2
<content goes here>
\folder n
<content goes here>
\includes
<include files e.g. JavaScript etc go here>
\master
<master pages go here>
default.aspx
Global.asax
Web.config

 
 
 

Master Pages and content pages in subfolder

Post by apatheti » Sun, 15 Oct 2006 03:00:10


<img runat="server" src="~/images/my-pic.jpg" />
 
 
 

Master Pages and content pages in subfolder

Post by vikram » Sun, 15 Oct 2006 04:07:11

Hi apathetic,

thanks for the solution. It worked fine using ~ to specify the path.