What is best way to reference directory from different locations?

Discussion in 'ASP .Net Web Controls' started by Kent P. Iler, Sep 30, 2004.

  1. Kent P. Iler

    Kent P. Iler Guest

    Hi,

    I am trying to reference images from an images directory immediately off the
    root level. The problem is that on my dev machine, the url is
    <machine>/hbmlocal/images, and on the production server, the url is
    <machine>/images

    I've tried using the "~" operator along with runat="server", and that works
    most of the time. However, I have a situation in a user control where the
    "~" isn't working. Here is the line:

    td runat="server" rowspan="4" width="100%"
    style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    repeat-x"

    I'm including this user control from multiple files at different directory
    levels, so I can't just use "../..", etc.

    Any suggestions?

    Thanks.

    -- Kent Iler
    ----------------------------------------------------------------------

    Please CC: all replies via e-mail
    Remove .NOSPAM from e-mail address
     
    Kent P. Iler, Sep 30, 2004
    #1
    1. Advertising

  2. Kent P. Iler

    ENIZIN Guest

    You might try creating a BaseURL setting in your web.config and make it a
    property of your page. Then you can reference it like

    <img src="<%=this.BaseURL%>/images/button.gif">

    "Kent P. Iler" wrote:

    > Hi,
    >
    > I am trying to reference images from an images directory immediately off the
    > root level. The problem is that on my dev machine, the url is
    > <machine>/hbmlocal/images, and on the production server, the url is
    > <machine>/images
    >
    > I've tried using the "~" operator along with runat="server", and that works
    > most of the time. However, I have a situation in a user control where the
    > "~" isn't working. Here is the line:
    >
    > td runat="server" rowspan="4" width="100%"
    > style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    > repeat-x"
    >
    > I'm including this user control from multiple files at different directory
    > levels, so I can't just use "../..", etc.
    >
    > Any suggestions?
    >
    > Thanks.
    >
    > -- Kent Iler
    > ----------------------------------------------------------------------
    >
    > Please CC: all replies via e-mail
    > Remove .NOSPAM from e-mail address
    >
    >
    >
     
    ENIZIN, Sep 30, 2004
    #2
    1. Advertising

  3. Kent P. Iler

    Kent P. Iler Guest

    Is there a reason why the "~" won't work?

    I'd have to have some logic to pull the server name so that it auto-sets
    based on if it's on the dev or production server.

    Thanks for your reply!

    --Kent

    "ENIZIN" <> wrote in message
    news:...
    > You might try creating a BaseURL setting in your web.config and make it a
    > property of your page. Then you can reference it like
    >
    > <img src="<%=this.BaseURL%>/images/button.gif">
    >
    > "Kent P. Iler" wrote:
    >
    > > Hi,
    > >
    > > I am trying to reference images from an images directory immediately off

    the
    > > root level. The problem is that on my dev machine, the url is
    > > <machine>/hbmlocal/images, and on the production server, the url is
    > > <machine>/images
    > >
    > > I've tried using the "~" operator along with runat="server", and that

    works
    > > most of the time. However, I have a situation in a user control where

    the
    > > "~" isn't working. Here is the line:
    > >
    > > td runat="server" rowspan="4" width="100%"
    > > style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    > > repeat-x"
    > >
    > > I'm including this user control from multiple files at different

    directory
    > > levels, so I can't just use "../..", etc.
    > >
    > > Any suggestions?
    > >
    > > Thanks.
    > >
    > > -- Kent Iler
    > > ----------------------------------------------------------------------
    > >
    > > Please CC: all replies via e-mail
    > > Remove .NOSPAM from e-mail address
    > >
    > >
    > >
     
    Kent P. Iler, Oct 1, 2004
    #3
  4. The ~ works for server side resolution of an address. It resolves to the
    root path of the application. Using the style attribute is client side.
    The browser doesn't know how to process the ~.

    I use to different version of my web.config, one for each server. It is a
    little more maintenance setting up, but once the web.configs are fairly
    static, there isn't really a problem.

    bill

    "Kent P. Iler" <> wrote in message
    news:3427d.295574$Fg5.21534@attbi_s53...
    > Is there a reason why the "~" won't work?
    >
    > I'd have to have some logic to pull the server name so that it auto-sets
    > based on if it's on the dev or production server.
    >
    > Thanks for your reply!
    >
    > --Kent
    >
    > "ENIZIN" <> wrote in message
    > news:...
    > > You might try creating a BaseURL setting in your web.config and make it

    a
    > > property of your page. Then you can reference it like
    > >
    > > <img src="<%=this.BaseURL%>/images/button.gif">
    > >
    > > "Kent P. Iler" wrote:
    > >
    > > > Hi,
    > > >
    > > > I am trying to reference images from an images directory immediately

    off
    > the
    > > > root level. The problem is that on my dev machine, the url is
    > > > <machine>/hbmlocal/images, and on the production server, the url is
    > > > <machine>/images
    > > >
    > > > I've tried using the "~" operator along with runat="server", and that

    > works
    > > > most of the time. However, I have a situation in a user control where

    > the
    > > > "~" isn't working. Here is the line:
    > > >
    > > > td runat="server" rowspan="4" width="100%"
    > > > style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    > > > repeat-x"
    > > >
    > > > I'm including this user control from multiple files at different

    > directory
    > > > levels, so I can't just use "../..", etc.
    > > >
    > > > Any suggestions?
    > > >
    > > > Thanks.
    > > >
    > > > -- Kent Iler
    > > > ----------------------------------------------------------------------
    > > >
    > > > Please CC: all replies via e-mail
    > > > Remove .NOSPAM from e-mail address
    > > >
    > > >
    > > >

    >
    >
     
    William F. Robertson, Jr., Oct 1, 2004
    #4
  5. For client paths I normally don't make a property like that, but just do the
    following:
    <%=Request.ApplicationPath%>

    --
    RobertK
    { Clever? No just smart. }

    "ENIZIN" <> wrote in message
    news:...
    > You might try creating a BaseURL setting in your web.config and make it a
    > property of your page. Then you can reference it like
    >
    > <img src="<%=this.BaseURL%>/images/button.gif">
    >
    > "Kent P. Iler" wrote:
    >
    > > Hi,
    > >
    > > I am trying to reference images from an images directory immediately off

    the
    > > root level. The problem is that on my dev machine, the url is
    > > <machine>/hbmlocal/images, and on the production server, the url is
    > > <machine>/images
    > >
    > > I've tried using the "~" operator along with runat="server", and that

    works
    > > most of the time. However, I have a situation in a user control where

    the
    > > "~" isn't working. Here is the line:
    > >
    > > td runat="server" rowspan="4" width="100%"
    > > style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    > > repeat-x"
    > >
    > > I'm including this user control from multiple files at different

    directory
    > > levels, so I can't just use "../..", etc.
    > >
    > > Any suggestions?
    > >
    > > Thanks.
    > >
    > > -- Kent Iler
    > > ----------------------------------------------------------------------
    > >
    > > Please CC: all replies via e-mail
    > > Remove .NOSPAM from e-mail address
    > >
    > >
    > >
     
    Robert Koritnik, Oct 1, 2004
    #5
  6. Kent P. Iler

    Kent P. Iler Guest

    Thank you!

    I think that's the way I'll also implement this.

    --Kent

    "Robert Koritnik" <> wrote in message news:<>...
    > For client paths I normally don't make a property like that, but just do the
    > following:
    > <%=Request.ApplicationPath%>
    >
    > --
    > RobertK
    > { Clever? No just smart. }
    >
    > "ENIZIN" <> wrote in message
    > news:...
    > > You might try creating a BaseURL setting in your web.config and make it a
    > > property of your page. Then you can reference it like
    > >
    > > <img src="<%=this.BaseURL%>/images/button.gif">
    > >
    > > "Kent P. Iler" wrote:
    > >
    > > > Hi,
    > > >
    > > > I am trying to reference images from an images directory immediately off

    > the
    > > > root level. The problem is that on my dev machine, the url is
    > > > <machine>/hbmlocal/images, and on the production server, the url is
    > > > <machine>/images
    > > >
    > > > I've tried using the "~" operator along with runat="server", and that

    > works
    > > > most of the time. However, I have a situation in a user control where

    > the
    > > > "~" isn't working. Here is the line:
    > > >
    > > > td runat="server" rowspan="4" width="100%"
    > > > style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    > > > repeat-x"
    > > >
    > > > I'm including this user control from multiple files at different

    > directory
    > > > levels, so I can't just use "../..", etc.
    > > >
    > > > Any suggestions?
    > > >
    > > > Thanks.
    > > >
    > > > -- Kent Iler
    > > > ----------------------------------------------------------------------
    > > >
    > > > Please CC: all replies via e-mail
    > > > Remove .NOSPAM from e-mail address
    > > >
    > > >
    > > >
     
    Kent P. Iler, Oct 3, 2004
    #6
  7. Kent P. Iler

    Kent P. Iler Guest

    Well, I used this and it worked great in my dev environment. However,
    when I copied the project to my production server, the reference is
    completely removing the server name. For example, an image tag should
    have the reference http://localserver/project/images/pic1.jpg on my
    dev machine, and on the production server the reference should be
    http://prodserver/images/pic1.jpg. However, on production, the image
    reference is set to http://images/pic1.jpg.

    Any suggestions?

    Thanks again!

    --Kent Iler

    (Kent P. Iler) wrote in message news:<>...
    > Thank you!
    >
    > I think that's the way I'll also implement this.
    >
    > --Kent
    >
    > "Robert Koritnik" <> wrote in message news:<>...
    > > For client paths I normally don't make a property like that, but just do the
    > > following:
    > > <%=Request.ApplicationPath%>
    > >
    > > --
    > > RobertK
    > > { Clever? No just smart. }
    > >
    > > "ENIZIN" <> wrote in message
    > > news:...
    > > > You might try creating a BaseURL setting in your web.config and make it a
    > > > property of your page. Then you can reference it like
    > > >
    > > > <img src="<%=this.BaseURL%>/images/button.gif">
    > > >
    > > > "Kent P. Iler" wrote:
    > > >
    > > > > Hi,
    > > > >
    > > > > I am trying to reference images from an images directory immediately off

    > the
    > > > > root level. The problem is that on my dev machine, the url is
    > > > > <machine>/hbmlocal/images, and on the production server, the url is
    > > > > <machine>/images
    > > > >
    > > > > I've tried using the "~" operator along with runat="server", and that

    > works
    > > > > most of the time. However, I have a situation in a user control where

    > the
    > > > > "~" isn't working. Here is the line:
    > > > >
    > > > > td runat="server" rowspan="4" width="100%"
    > > > > style="BACKGROUND-IMAGE:~/Images/drill_left.gif; BACKGROUND-REPEAT:
    > > > > repeat-x"
    > > > >
    > > > > I'm including this user control from multiple files at different

    > directory
    > > > > levels, so I can't just use "../..", etc.
    > > > >
    > > > > Any suggestions?
    > > > >
    > > > > Thanks.
    > > > >
    > > > > -- Kent Iler
    > > > > ----------------------------------------------------------------------
    > > > >
    > > > > Please CC: all replies via e-mail
    > > > > Remove .NOSPAM from e-mail address
    > > > >
    > > > >
    > > > >
     
    Kent P. Iler, Oct 6, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam-I-Am
    Replies:
    2
    Views:
    295
    Steven Cheng[MSFT]
    May 11, 2004
  2. =?Utf-8?B?TWF0dA==?=
    Replies:
    0
    Views:
    372
    =?Utf-8?B?TWF0dA==?=
    May 20, 2004
  3. =?Utf-8?B?TWF0dA==?=
    Replies:
    3
    Views:
    515
    Mike Smith
    Jul 20, 2004
  4. =?Utf-8?B?TWF0dA==?=
    Replies:
    0
    Views:
    334
    =?Utf-8?B?TWF0dA==?=
    Jul 20, 2004
  5. Kent P. Iler
    Replies:
    6
    Views:
    403
    Kent P. Iler
    Oct 6, 2004
Loading...

Share This Page