How to relatively reference the path in c# asp.net

S

Scott Allen

Hi Annie,

I'm not entirely clear what you are looking for.

Are you looking for ways to reference files in the mobile images
directory? You can use "~" as in:

<asp:Image
runat="server" ID="Image1"
ImageUrl="~/MobileImages/foo.png" />
 
J

jasonkester

Depends on where you're trying to reference the path.

In HTML, you'll use a server-relative path:
<img src="/MobileShop/MobileImages/myimage.gif">

For runat=server controls, you can use ~/ shorthand for
application-relative paths:
<img src="~/MobileImages/myimage.gif">

For more granular control, and for manipulating files on the server,
you have all sorts of methods in the CLR to map paths. Most useful to
you is probably Server.MapPath().


Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
 
A

Annie

Thanks Jason. That is what i wanted. bcoz i was confused with all these
differences!
cheers!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top