Need help referencing files

Last post 07-05-2009 12:43 AM by Bobby-Z. 2 replies.

Sort Posts:

  • Need help referencing files

    07-04-2009, 2:13 AM
    • Member
      1 point Member
    • kiloez
    • Member since 06-13-2009, 10:29 AM
    • Posts 8

     I'd like to be able to keep like files in separate folders for a web site.  Master pages go in a master pages folder, style sheets go in a CSS folder, etc.  However, my master pages can't find the CSS files.  I get a 'File....css' was not found.  The style sheet ref in the master page is referenced as follows:

    <link href="CSS/stylesheet.css" rel="stylesheet" type="text/css" />

    but it's not working.  Please help.

  • Re: Need help referencing files

    07-04-2009, 6:06 AM
    Answer
    • All-Star
      60,792 point All-Star
    • anas
    • Member since 09-21-2006, 4:31 AM
    • Palestinian Territory, Occupied
    • Posts 6,848
    • Moderator

    kiloez:
    <link href="CSS/stylesheet.css" rel="stylesheet" type="text/css" />

    Please use ResolveUrl method for that purpose :

    <link href="<%= ResolveUrl("~/CSS/stylesheet.css") %>" rel="stylesheet" type="text/css" />


    Regards,

    Anas Ghanem | Blog

  • Re: Need help referencing files

    07-05-2009, 12:43 AM
    Answer
    • Member
      650 point Member
    • Bobby-Z
    • Member since 10-04-2008, 1:53 AM
    • Orange County, CA
    • Posts 297

     the above is a great solution, a simple one would be href="../CSS/Stylesheet.css"

    I was using the same format

    /Master

    /CSS

    If you do this you need to add the ../ to the file to backup one folder from the one you are currently in

    Is there a reason why you are not using a Theme - In a theme you place both your skin file and css in the same directory under the APP_THEMES

    /App_Themes/MainTheme

    Then at the page directive or in web.config you simply state Theme="MainTheme" StyleSheetTheme="MainTheme"

    http://www.asp.net/learn/videos/video-393.aspx this video shows how easy it is. If you need help - I can post more info for you.

    This is also a simple way to have multiple themes and link the directly to each page you want wach theme to be.

    "Success is the Sum of Small Efforts, Repeated Day in and Day Out - Without Ceasing!"

    Robert Hall
    CEO and Founder
    My Service Solutions, Inc.
Page 1 of 1 (3 items)