|
|
|
start date: Tue, 21 Aug 2007 03:06:16 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
NightOwl888
|
|
2
David Wier
|
MasterPage subdirectory and ResolveUrl - not working correctly
I have an older web project that I am trying to update with new .NET
2.0 features.
I put new master pages in a subdirectory below the project directory.
This particular project runs under IIS (rather than using a file
location). So, the directory that my master pages are in looks like
this:
C:\inetpub\wwwroot\MyProject\MasterPages\
All of my content pages are located under \MyProject. All of the user
controls for the project are located under \MyProject\UserControls.
Now, the issue I am having is that I have usercontrols that I am
putting onto the master page. These user controls contain references
to images. I had already gone through the whole site before starting
to use master pages and put code similar to the following on all URL
references in the user controls:
Me.hlLogo.NavigateUrl = Me.Parent.ResolveUrl("~/Images/Logo.gif")
This resolved the references to the images perfectly when it was
executed within a user control. For example:
<img src="/MyProject/Images/Logo.gif"></img>
It even worked when the page that contained the master page was
several levels below the /MyProject directory.
However, now that the user control is on a master page, I am getting
the following error when trying to resolve the URLs using ResolveUrl.
<img src="/MyProject/MasterPages/Images/Logo.gif"></img>
I searched everywhere and I can't seem to find anyone that had this
particular issue. Is there a limitation on Master Pages that they
can't be placed in a subdirectory without the content pages? If not,
why is this path coming up with ResolveUrl?
By the way, I tried changing the code in my user control to something
more like...
Me.hlLogo.NavigateUrl = Me.Parent.Parent.ResolveUrl("~/Images/
Logo.gif")
....and...
Me.hlLogo.NavigateUrl = Me.Parent.Page.ResolveUrl("~/Images/Logo.gif")
....but I always get the same result in every case.
Date:Tue, 21 Aug 2007 03:06:16 -0700
Author:
|
Re: MasterPage subdirectory and ResolveUrl - not working correctly
Change the image tag, to an ASP.Net Image tag - - you can use:
("~/Images/Logo.gif")
David Wier
http://aspnet101.com
http://iWritePro.com - export to PDF/HTML
"NightOwl888" wrote in message
news:1187690776.161539.30420@q3g2000prf.googlegroups.com...
>I have an older web project that I am trying to update with new .NET
> 2.0 features.
>
> I put new master pages in a subdirectory below the project directory.
> This particular project runs under IIS (rather than using a file
> location). So, the directory that my master pages are in looks like
> this:
>
> C:\inetpub\wwwroot\MyProject\MasterPages\
>
> All of my content pages are located under \MyProject. All of the user
> controls for the project are located under \MyProject\UserControls.
>
> Now, the issue I am having is that I have usercontrols that I am
> putting onto the master page. These user controls contain references
> to images. I had already gone through the whole site before starting
> to use master pages and put code similar to the following on all URL
> references in the user controls:
>
> Me.hlLogo.NavigateUrl = Me.Parent.ResolveUrl("~/Images/Logo.gif")
>
> This resolved the references to the images perfectly when it was
> executed within a user control. For example:
>
> <img src="/MyProject/Images/Logo.gif"></img>
>
> It even worked when the page that contained the master page was
> several levels below the /MyProject directory.
>
> However, now that the user control is on a master page, I am getting
> the following error when trying to resolve the URLs using ResolveUrl.
>
> <img src="/MyProject/MasterPages/Images/Logo.gif"></img>
>
> I searched everywhere and I can't seem to find anyone that had this
> particular issue. Is there a limitation on Master Pages that they
> can't be placed in a subdirectory without the content pages? If not,
> why is this path coming up with ResolveUrl?
>
> By the way, I tried changing the code in my user control to something
> more like...
>
> Me.hlLogo.NavigateUrl = Me.Parent.Parent.ResolveUrl("~/Images/
> Logo.gif")
>
> ...and...
>
> Me.hlLogo.NavigateUrl = Me.Parent.Page.ResolveUrl("~/Images/Logo.gif")
>
> ...but I always get the same result in every case.
>
Date:Tue, 21 Aug 2007 08:43:40 -0500
Author:
|
|
|