problem with relative paths in VS/VB.net

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

hello,
i almost feel stupid asking about this topic, but since i'm new to
vb.net what the hell....
i'm having a ridiculously hard time to get paths to be recognized
within aspx pages.
here is what i found (using VS 2003)

/images/img.gif is invalid in VS, doesn't work in browser
.../images/img.gif is valid in VS, but does not display in browser

http://localhost/Test1/images/logo.gif works

images\logo.gif works in browser, but not in design mode (this also
assumes your are in a page at the root level.

\images\logo.gif doesn't work in either

this is nuts! or i'm just stupid....

every other language i've dealt with the "/" would be the root and if
your pics are in the images directory then "/images/xyz.gif" would
access it.

what the hell am i missing? thanks :)
 
Simon,

Why not just import an image in your solution in the imagefolder of that
Than set the image property as I told in the other message "image button" to
that image.

I hope this helps (I am not 100% sure),

Cor
 
hello. thanks for the reply, that only works if the image is pulled
in via the toolbar. what i was looking to do is some straight html
coding via the "code view". that is where i'm getting killed....
 
hi again. thanks as always for the replies. i was trying to reuse
some existing html i have from previous projects. and when you code
html in the "code view" it seems to not resolve paths correctly,
sometimes in the design view or in the executed browser display.
do all vb.net programmers do everything via dragging objects in and
setting properties, would think straight coding in the code view is
used as much? i'm sure most has to be because i'm new to this
language/platform. this is an odd one. if i had to recreate all this
stuff by dragging,dropping, prop setting it would take a serious long
time. hope there is something i can do.

thanks again. this group is awesome for help and it is really
appreciated!!!
 
(Server.MapPath won't really help him if he's trying to straighten out how
to reference paths in basic HTML in ASPX pages.)

Simon, it sounds like you're used to always working in a web site's "root."
ASP.NET apps like to be in subfolders. :-)
For basic HTML (non ASP controls):

images/logo.gif: This is what I think you're looking for. It means the
images subfolder is in the same folder that the page is in. Note the lack of
the first forward slash. In your example you tried this but with a backslash
instead of the standard html forward slash.

/images/logo.gif: means the images folder is in the *root of the web server*
regardless of the page OR your web application's subfolder. This is not a
"relative" path.

By the way these are client-side browser semantics... not ASP.NET.

~/images/logo.gif only works for server-side controls. Browsers have no idea
what ~/ means.
 
Simon,

Although HTML and Javascript has been a long time very easy for me (it still
is, however now I have to remember me more), do I try to avoid to write in
ASPNET as much as possible in HTML and Javascript. Reason, I don't want to
let the user direct when he does "Source Code" to show him everything.
(Although in this case it will be direct placed in the attributes from the
control).

Why would I not use the property box or other things like that, that give
me good maintanable programs

Just my thought,

:-)

Cor
 

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

Back
Top