Solved

Calling User Controls from pages within different directories

Posted on 2003-11-27
4
285 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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