Use of Tilde (~) and <LINK>

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 10, 2004.

  1. I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as the control in which it's used is set to runat="server". It's very handy.

    Here's the problem. I have
    <link rel="STYLESHEET" type="text/css" href="/Shared/CSS/Global.css" /
    on every page of the site. I REALLY want to be able to locate the href of this link using the ~ so that it's relative to the application root rather than the IIS docroot. But it doesn't seem like there's any way to do that.

    Ideas

    Ale
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 10, 2004
    #1
    1. Advertising

  2. Alex Maghen wrote:
    > I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as the control in which it's used is set to runat="server". It's very handy.
    >
    > Here's the problem. I have
    > <link rel="STYLESHEET" type="text/css" href="/Shared/CSS/Global.css" />
    > on every page of the site. I REALLY want to be able to locate the href of this link using the ~ so that it's relative to the application root rather than the IIS docroot. But it doesn't seem like there's any way to do that.
    >
    > Ideas?


    How about putting:

    <asp:LiteralControl runat="server" id="linkLit" />

    The in Page_Load putting:

    linkLit.Text = String.Format("<link rel=""STYLESHEET"" type=""text/css""
    href=""{0}"" />", Page.ResolveUrl("~/Global.css (or whatever)"))


    hth

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], May 10, 2004
    #2
    1. Advertising

  3. Yeah, that's what I'm doin'. Don't love it but it does the job. Thanks

    ----- Scott Mitchell [MVP] wrote: ----

    Alex Maghen wrote
    > I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as the control in which it's used is set to runat="server". It's very handy.
    >> Here's the problem. I have

    ><link rel="STYLESHEET" type="text/css" href="/Shared/CSS/Global.css" />> on every page of the site. I REALLY want to be able to locate the href of this link using the ~ so that it's relative to the application root rather than the IIS docroot. But it doesn't seem like there's any way to do that.
    >> Ideas


    How about putting

    <asp:LiteralControl runat="server" id="linkLit" /

    The in Page_Load putting

    linkLit.Text = String.Format("<link rel=""STYLESHEET"" type=""text/css""
    href=""{0}"" />", Page.ResolveUrl("~/Global.css (or whatever)")


    ht

    --

    Scott Mitchel

    http://www.4GuysFromRolla.co
    http://www.ASPFAQs.co
    http://www.ASPMessageboard.co

    * When you think ASP, think 4GuysFromRolla.com
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 11, 2004
    #3
    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. SStory

    Tilde for relative path

    SStory, Oct 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,753
    SStory
    Oct 19, 2003
  2. CHristian Niss
    Replies:
    0
    Views:
    472
    CHristian Niss
    Oct 31, 2003
  3. MB2

    Tilde Expansion

    MB2, Sep 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    447
    Rick Strahl [MVP]
    Sep 24, 2004
  4. Arjen

    AppPath and tilde

    Arjen, Aug 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    414
    Curt_C [MVP]
    Aug 3, 2005
  5. Krispen Hartung
    Replies:
    1
    Views:
    675
    Hywel Jenkins
    Dec 11, 2004
Loading...

Share This Page