Solved

Calling User Controls from pages within different directories

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C# Export DataGridView 4 41
Trouble with References... 5 25
index Out OF Range Exception error 4 32
XML & .net 5 21
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

18 Experts available now in Live!

Get 1:1 Help Now