Implementing ~/...

Discussion in 'ASP .Net' started by Jonathan Wood, Jan 31, 2007.

  1. I am creating some custom links via code on my Web site.

    One problem I have is that I might write a link as /Images/img.gif. On my
    Web site, that should work find. But on my local test computer, it is wrong
    because / actual refers to the root of my developer server folder.

    What I really want is ~/Images/img.gif but I'm not using a label control. Is
    there a function that will take ~/Images... and change it to be the path off
    my project's root dir? Perhaps the same routine called by the label
    controls, etc?

    Thanks for any tips.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
    Jonathan Wood, Jan 31, 2007
    #1
    1. Advertising

  2. Jonathan Wood

    Patrice Guest

    AFAIK this is Control.ResolveUrl. Try
    http://msdn2.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx...

    "Jonathan Wood" <> a écrit dans le message de news:
    uR$...
    >I am creating some custom links via code on my Web site.
    >
    > One problem I have is that I might write a link as /Images/img.gif. On my
    > Web site, that should work find. But on my local test computer, it is
    > wrong because / actual refers to the root of my developer server folder.
    >
    > What I really want is ~/Images/img.gif but I'm not using a label control.
    > Is there a function that will take ~/Images... and change it to be the
    > path off my project's root dir? Perhaps the same routine called by the
    > label controls, etc?
    >
    > Thanks for any tips.
    >
    > --
    > Jonathan Wood
    > SoftCircuits Programming
    > http://www.softcircuits.com
    >
    >
    Patrice, Jan 31, 2007
    #2
    1. Advertising

  3. Jonathan,

    I am not sure why can't you use ~/Images/img.gif as it is. Asp.Net will
    compile this reference to Request.ApplicationPath. Obviously, it will work
    only for server-side controls, but you can turn any control to a server-side
    one by just adding runat=server.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Jonathan Wood" <> wrote in message
    news:uR$...
    >I am creating some custom links via code on my Web site.
    >
    > One problem I have is that I might write a link as /Images/img.gif. On my
    > Web site, that should work find. But on my local test computer, it is
    > wrong because / actual refers to the root of my developer server folder.
    >
    > What I really want is ~/Images/img.gif but I'm not using a label control.
    > Is there a function that will take ~/Images... and change it to be the
    > path off my project's root dir? Perhaps the same routine called by the
    > label controls, etc?
    >
    > Thanks for any tips.
    >
    > --
    > Jonathan Wood
    > SoftCircuits Programming
    > http://www.softcircuits.com
    >
    >
    Eliyahu Goldin, Jan 31, 2007
    #3
  4. Control.ResolveUrl produces an url usable on client side. If I understand
    Jonathan correctly, he needs to get right the server-side reference, that it
    what Control.ResolveUrl takes to produce a client-side reference.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Patrice" <http://www.chez.com/scribe/> wrote in message
    news:eIvK$%...
    > AFAIK this is Control.ResolveUrl. Try
    > http://msdn2.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx...
    >
    > "Jonathan Wood" <> a écrit dans le message de news:
    > uR$...
    >>I am creating some custom links via code on my Web site.
    >>
    >> One problem I have is that I might write a link as /Images/img.gif. On my
    >> Web site, that should work find. But on my local test computer, it is
    >> wrong because / actual refers to the root of my developer server folder.
    >>
    >> What I really want is ~/Images/img.gif but I'm not using a label control.
    >> Is there a function that will take ~/Images... and change it to be the
    >> path off my project's root dir? Perhaps the same routine called by the
    >> label controls, etc?
    >>
    >> Thanks for any tips.
    >>
    >> --
    >> Jonathan Wood
    >> SoftCircuits Programming
    >> http://www.softcircuits.com
    >>
    >>

    >
    >
    Eliyahu Goldin, Jan 31, 2007
    #4
  5. Jonathan Wood

    Patrice Guest

    Then it would be Server.MapPath. As Jonathan talked about a "link" I thought
    the problem was that the hyperlink is not correct client side...

    Jonathan, as suggested by Eliyahu you could perhaps still have this done
    automatically. We know that you don't use a label but you may want to tell
    use which control exactly you are using...

    ----
    Patrice

    "Eliyahu Goldin" <> a écrit dans le
    message de news: ...
    > Control.ResolveUrl produces an url usable on client side. If I understand
    > Jonathan correctly, he needs to get right the server-side reference, that
    > it what Control.ResolveUrl takes to produce a client-side reference.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Patrice" <http://www.chez.com/scribe/> wrote in message
    > news:eIvK$%...
    >> AFAIK this is Control.ResolveUrl. Try
    >> http://msdn2.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx...
    >>
    >> "Jonathan Wood" <> a écrit dans le message de news:
    >> uR$...
    >>>I am creating some custom links via code on my Web site.
    >>>
    >>> One problem I have is that I might write a link as /Images/img.gif. On
    >>> my Web site, that should work find. But on my local test computer, it is
    >>> wrong because / actual refers to the root of my developer server folder.
    >>>
    >>> What I really want is ~/Images/img.gif but I'm not using a label
    >>> control. Is there a function that will take ~/Images... and change it to
    >>> be the path off my project's root dir? Perhaps the same routine called
    >>> by the label controls, etc?
    >>>
    >>> Thanks for any tips.
    >>>
    >>> --
    >>> Jonathan Wood
    >>> SoftCircuits Programming
    >>> http://www.softcircuits.com
    >>>
    >>>

    >>
    >>

    >
    >
    Patrice, Jan 31, 2007
    #5
  6. I'm emitting HTML in a control's Render event via writer.Write().

    If I emit a path with ~/, that will pass unchanged to the web page.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com

    "Eliyahu Goldin" <> wrote in
    message news:...
    > Jonathan,
    >
    > I am not sure why can't you use ~/Images/img.gif as it is. Asp.Net will
    > compile this reference to Request.ApplicationPath. Obviously, it will work
    > only for server-side controls, but you can turn any control to a
    > server-side one by just adding runat=server.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Jonathan Wood" <> wrote in message
    > news:uR$...
    >>I am creating some custom links via code on my Web site.
    >>
    >> One problem I have is that I might write a link as /Images/img.gif. On my
    >> Web site, that should work find. But on my local test computer, it is
    >> wrong because / actual refers to the root of my developer server folder.
    >>
    >> What I really want is ~/Images/img.gif but I'm not using a label control.
    >> Is there a function that will take ~/Images... and change it to be the
    >> path off my project's root dir? Perhaps the same routine called by the
    >> label controls, etc?
    >>
    >> Thanks for any tips.
    >>
    >> --
    >> Jonathan Wood
    >> SoftCircuits Programming
    >> http://www.softcircuits.com
    >>
    >>

    >
    >
    Jonathan Wood, Jan 31, 2007
    #6
  7. Yep, that did it. Thanks!

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com

    "Patrice" <http://www.chez.com/scribe/> wrote in message
    news:eIvK$%...
    > AFAIK this is Control.ResolveUrl. Try
    > http://msdn2.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx...
    >
    > "Jonathan Wood" <> a écrit dans le message de news:
    > uR$...
    >>I am creating some custom links via code on my Web site.
    >>
    >> One problem I have is that I might write a link as /Images/img.gif. On my
    >> Web site, that should work find. But on my local test computer, it is
    >> wrong because / actual refers to the root of my developer server folder.
    >>
    >> What I really want is ~/Images/img.gif but I'm not using a label control.
    >> Is there a function that will take ~/Images... and change it to be the
    >> path off my project's root dir? Perhaps the same routine called by the
    >> label controls, etc?
    >>
    >> Thanks for any tips.
    >>
    >> --
    >> Jonathan Wood
    >> SoftCircuits Programming
    >> http://www.softcircuits.com
    >>
    >>

    >
    >
    Jonathan Wood, Jan 31, 2007
    #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. Gomathi

    Implementing Interface

    Gomathi, Nov 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    551
    S.M. Altaf [MVP]
    Nov 17, 2005
  2. Eqbal Z
    Replies:
    3
    Views:
    5,069
    Eqbal
    Nov 16, 2003
  3. Dev

    Implementing E1 - E3

    Dev, Sep 9, 2004, in forum: VHDL
    Replies:
    1
    Views:
    714
    Allan Herriman
    Sep 9, 2004
  4. Johnsy Joseph
    Replies:
    2
    Views:
    1,085
    Brian Drummond
    Oct 29, 2004
  5. Riccardo Fregonese

    Need help implementing a proj on SPARTAN3

    Riccardo Fregonese, Dec 2, 2004, in forum: VHDL
    Replies:
    2
    Views:
    703
    Thomas Gebauer
    Jan 3, 2005
Loading...

Share This Page