Img Source proglem

Last post 05-09-2008 2:48 PM by allanhorwitz. 18 replies.

Sort Posts:

  • Re: Img Source proglem

    05-07-2008, 3:08 AM
    • Loading...
    • mbanavige
    • Joined on 11-06-2003, 1:29 PM
    • New England, USA
    • Posts 6,938
    • Moderator
      TrustedFriends-MVPs

    you need to give the td a class attribute and remove the style tag from the td. you should not put the styles directly in the markup but you should instead put them in the stylesheet.  in this way, the image path for the url() used in the background-image style is relative to where the stylesheet is stored.

    Mike Banavige
    ~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Img Source proglem

    05-07-2008, 12:43 PM
    • Loading...
    • danishjee
    • Joined on 10-31-2007, 11:06 AM
    • Pakistani
    • Posts 63

    HI,

    Thanks for ur fast reply.would u plz give me example code.

    Regards,

  • Re: Img Source proglem

    05-08-2008, 10:57 PM
    • Loading...
    • mbanavige
    • Joined on 11-06-2003, 1:29 PM
    • New England, USA
    • Posts 6,938
    • Moderator
      TrustedFriends-MVPs

    In a css sheet (MyStyles.css) stored in you apps root folder, you can set your urls like this: 

    .someCssClass { 
        background-image: url('imgs/topbg.png'); 
        background-repeat: no-repeat; 
        background-position: center center; 
        text-align: center;
    }
     
    Since this image path in the css sheet is relative to where the css sheet is stored it will work whether the web page is pulled from your site root or from a subfolder.

    In your masterpage head section you can add a link to that css sheet like this:

    <link runat="server" 
          id="csslnk1"
          href="~/MyStyles.css"
          rel="stylesheet" type="text/css" />

    This link uses a root relative syntax (using the ~/) so the stylesheet can be found no matter what folder/subfolder your page is being pulled from.

    Then you can set your td background-image style inside that page by using a class selector like this:

    <td class="someCssClass">
     
    Mike Banavige
    ~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Img Source proglem

    05-09-2008, 2:48 PM
    • Loading...
    • allanhorwitz
    • Joined on 04-10-2008, 1:45 PM
    • Philadelphia, PA
    • Posts 302

    allanhorwitz:
    That "~" sign may be the right way to do it, but in my experience, it just does not work right. My earlier post was marked as the answer.

    Thank you, Mike, for showing me the error of my ways. And, also for the CSS tutorial.

    Allan Horwitz
Page 2 of 2 (19 items) < Previous 1 2