Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

MasterPage subdirectory and ResolveUrl - not working correctly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NightOwl888 - 21 Aug 2007 11:06 GMT
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.
David Wier - 21 Aug 2007 14:43 GMT
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

>I have an older web project that I am trying to update with new .NET
> 2.0 features.
[quoted text clipped - 46 lines]
>
> ...but I always get the same result in every case.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.