problem with relative paths in VS/VB.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • simon

    #1

    problem with relative paths in VS/VB.net

    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.gi f 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 :)

  • Cor Ligthert [MVP]

    #2
    Re: problem with relative paths in VS/VB.net

    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


    Comment

    • Ken Tucker [MVP]

      #3
      Re: problem with relative paths in VS/VB.net

      Hi,

      Try ~/images/img.gif

      Ken
      -------------
      "simon" <me@here.com> wrote in message
      news:rpsau19m67 4th3kt5qegf77o0 j178i11be@4ax.c om...[color=blue]
      > 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.gi f 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 :)
      >[/color]


      Comment

      • simon

        #4
        Re: problem with relative paths in VS/VB.net

        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....
        [color=blue]
        >
        > Try ~/images/img.gif
        >
        >Ken[/color]

        Comment

        • simon

          #5
          Re: problem with relative paths in VS/VB.net

          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,droppi ng, 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!!!
          [color=blue]
          >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
          >[/color]

          Comment

          • Ken Tucker [MVP]

            #6
            Re: problem with relative paths in VS/VB.net

            Hi,

            Take a look at server.mappath

            Ken
            -----------------------

            "simon" wrote:
            [color=blue]
            > 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....
            >[color=green]
            > >
            > > Try ~/images/img.gif
            > >
            > >Ken[/color]
            >
            >[/color]

            Comment

            • CMM

              #7
              Re: problem with relative paths in VS/VB.net

              (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.




              "Ken Tucker [MVP]" <KenTuckerMVP@d iscussions.micr osoft.com> wrote in message
              news:69AA9F94-2D5C-46DD-B84B-275BBF7EEC65@mi crosoft.com...[color=blue]
              > Hi,
              >
              > Take a look at server.mappath
              >
              > Ken
              > -----------------------
              >
              > "simon" wrote:
              >[color=green]
              >> 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....
              >>[color=darkred]
              >> >
              >> > Try ~/images/img.gif
              >> >
              >> >Ken[/color]
              >>
              >>[/color][/color]


              Comment

              • Cor Ligthert [MVP]

                #8
                Re: problem with relative paths in VS/VB.net

                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


                Comment

                Working...