Solved

Calling User Controls from pages within different directories

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Search by two fields at the same time using c# radio button 5 39
Error on Add method 1 38
Not showing JavaScript in the list 5 38
Wav problem 4 16
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now