N
NightOwl888
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.
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.