Solved

Calling User Controls from pages within different directories

Posted on 2003-11-27
4
292 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
[X]
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
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

628 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