User control + relative path

Discussion in 'ASP .Net Web Controls' started by Alex, Oct 18, 2004.

  1. Alex

    Alex Guest

    Hi. I need some help on this.
    I have a user control (a header) in my root directory, and all my pages use
    that control. Then a created a folder (in my root directory) and put a new
    page inside it, and that page use the same control, but this time the
    control can't find it's images and resources because it is trying to find it
    in the same folder instead of the root directory. Now, I know that I can
    change the control image's relative paths for absolute paths, but then when
    I upload my application to the real server I have to change all the paths
    again. Of course I could make a copy of the control in my new folder but
    then I have to copy all the images and everything too.
    Is there some simple way of dealing with that?
    Thanks,
    Alejandro Penate-Diaz.
    Alex, Oct 18, 2004
    #1
    1. Advertising

  2. Alex

    Drew Robbins Guest

    You can use a path like "~/Controls/MyControl.ascx". The '~' character
    is replaced with the Application root path at runtime. It's a nice
    compromise between relative and absolute paths.

    Alex wrote:
    > Hi. I need some help on this.
    > I have a user control (a header) in my root directory, and all my pages use
    > that control. Then a created a folder (in my root directory) and put a new
    > page inside it, and that page use the same control, but this time the
    > control can't find it's images and resources because it is trying to find it
    > in the same folder instead of the root directory. Now, I know that I can
    > change the control image's relative paths for absolute paths, but then when
    > I upload my application to the real server I have to change all the paths
    > again. Of course I could make a copy of the control in my new folder but
    > then I have to copy all the images and everything too.
    > Is there some simple way of dealing with that?
    > Thanks,
    > Alejandro Penate-Diaz.
    >
    >
    Drew Robbins, Oct 18, 2004
    #2
    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. Alex

    User control + relative path

    Alex, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,577
    learntonoob
    May 22, 2008
  2. Guadala Harry

    Specifying Root Relative Path in User Control

    Guadala Harry, Apr 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,030
    Karl Seguin
    Apr 27, 2005
  3. Matt
    Replies:
    3
    Views:
    19,514
    Sudsy
    Jul 8, 2004
  4. Oren
    Replies:
    1
    Views:
    527
    Michael D. Ober
    Apr 29, 2007
  5. Alex

    User control + relative path

    Alex, Oct 18, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    119
    A Traveler
    Oct 18, 2004
Loading...

Share This Page