Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Calling User Controls from pages within different directories

Posted on 2003-11-27
4
277 Views
Last Modified: 2010-04-16
I have an aspx file in the root of my application which calls a user control also sat in the root of my application.

My user control references images in an image directory off of the root. Example...

<img src="Images/MyPicture.jpg"    -    Everything works fine

If I call the same user control from an aspx page within a sub directory off of the root the user control obviously doesn't locate the images because it is looking for a directory called images in the sub directory I am currently in - It is not going back to the root

Anyone a solution without having to create another user control with a different path for the image

Thanks
0
Comment
Question by:carlmc
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
dcr25568 earned 500 total points
ID: 9830903
You can try using a universal link to the source of the image:

<img src="<%=Request.ApplicationPath%>/images/MyPicture.gif">

This should work fine from whichever directory you are calling it from, b/c it will force it to look at the application root.

Let me know if it helps, should be a simple search/replace to change it in your application.

Regards,
Doug
0
 

Author Comment

by:carlmc
ID: 9830920
Is this the C# syntax??
0
 
LVL 1

Expert Comment

by:dcr25568
ID: 9830932
Yes it is.  
0
 

Author Comment

by:carlmc
ID: 9830975
That works great - Thankyou very much

Such an easy solution!!!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question