Designating the Path to a File in a MasterPage and StyleSheet

Last post 10-28-2008 4:16 AM by raghav_khunger. 4 replies.

Sort Posts:

  • Designating the Path to a File in a MasterPage and StyleSheet

    10-27-2008, 3:17 PM
    • Member
      155 point Member
    • Chaplain Doug
    • Member since 10-09-2007, 3:27 PM
    • Richmond, Virginia
    • Posts 668

    VWD 2008 Express. Visual Basic.

    I have a MasterPage.master file and a StyleSheet.css file located in a subdirectory of my web site.  The subdirectory is called "Admninistration."

    1.  I want the MasterPage.master file in the Administration subdirectory to use the styles in the StyleSheet.css in the Administration subdirectory.  How should I specify this in the MasterPage.master file?

    • <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    • <link href="/Administration/StyleSheet.css" rel="stylesheet" type="text/css" />

    • <link href="~/Administration/StyleSheet.css" rel="stylesheet" type="text/css" />

    2.  I want the StyleSheet.css file to reference images stored in another subdirectory of the web site calle "Images."  How should I specify the URLs?

    • url(~/images/sidebar_header.png)

    • url(/images/sidebar_header.png)

    I have a dickens of a time getting the references to work.  Thanks for setting me straight on the convention.

    Dr. Douglas Pruiett
    Good News Jail & Prison Ministry
    www.goodnewsjail.org
  • Re: Designating the Path to a File in a MasterPage and StyleSheet

    10-27-2008, 3:46 PM

    Hello!

     

    As for your first question, I'd go with option number 3.

    Question number two, relative to the stylesheet and using quotes is good url('./yourImages/someImage.png').

    Cheers!

    /Eskil

  • Re: Designating the Path to a File in a MasterPage and StyleSheet

    10-27-2008, 6:26 PM
    • Member
      155 point Member
    • Chaplain Doug
    • Member since 10-09-2007, 3:27 PM
    • Richmond, Virginia
    • Posts 668

     

    body
    {
    	background: #B4B4B4 url(~/images/Backgrounds/body_bg.gif) repeat left top;
    	font-family: Tahoma, Arial, sans-serif;
    	font-size:75%;
    }
     It appears from all the examples I have seen that quotation marks are not used in the url designation in CSS pages.

    My StyleSheet.css resides in the same subfolder as the MasterPage.master that references it.  They both reside in a sunfolder called "Administration."  I have used the full path for image files in the CSS, but most still do not show up.  For example, in the MasterPage.master I have:

    <head id="MasterHead" runat="server">
        <link href="~/Administration/StyleSheet.css" rel="stylesheet" type="text/css" />
    </head>

     In the CSS sheet (StyleSheet.css) I have:

    body
    {
    	background: #B4B4B4 url(~/images/Backgrounds/body_bg.gif) repeat left top;
    	font-family: Tahoma, Arial, sans-serif;
    	font-size:75%;
    }
     HOWEVER, THE IMAGE never shows up in the background.
    Dr. Douglas Pruiett
    Good News Jail & Prison Ministry
    www.goodnewsjail.org
  • Re: Designating the Path to a File in a MasterPage and StyleSheet

    10-28-2008, 3:41 AM

    Hello,

    Try ommiting the ~ in your css code.

    Cheers!

    /Eskil

  • Re: Designating the Path to a File in a MasterPage and StyleSheet

    10-28-2008, 4:16 AM
    Answer
    • All-Star
      18,794 point All-Star
    • raghav_khunger
    • Member since 08-18-2008, 8:25 AM
    • Delhi, India
    • Posts 3,449
    • TrustedFriends-MVPs

    Hi,Chaplain Doug

    for Ur Case 

    Write in this way in your css file 

    background-image:url('../images/sidebar_header.png');

     

    and in ur aspx page to link that css

    write in this way

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

     

     

     

    PLZ MARK AS ANSWER IF IT HELP U.

    THANKS.
     

    Raghav CodeASP.NET Community | My Blog | jQuery Intellisense in Visual Studio 2008




    "Success doesn't come to you…you go to it."--Marva Collins

    "Failure is success if we learn from it." Malcolm Forbes

    "Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous


Page 1 of 1 (5 items)