Resolving URL() in CSS

Last post 05-04-2008 12:58 PM by timtas. 2 replies.

Sort Posts:

  • Resolving URL() in CSS

    05-04-2008, 11:46 AM
    • Loading...
    • timtas
    • Joined on 11-05-2005, 10:23 AM
    • Posts 16

    I just deployed my new MVC site to our test server.  It's IIS 6, and I finally got all the routing and content URL stuff working...well almost.  I am using the JQuery date picker, which uses CSS for the calendar image.  I have the following in a CSS class.

    background: url(../../Content/Images/calendar.png) no-repeat;

    Before I discovered this issue, It had discovered that "../../" is not treated as I expect.  I found this solution (Url.Content method), which works for view pages. However, obviously I cannot use that method in CSS.   I tried to solve it with routing per this post.  I tried by adding this to my main route: 

    Constraints= new RouteValueDictionary(new { id = "^(?!Content).*" }
    and then then this:
    Constraints= new RouteValueDictionary(new { id = "(?!Content).*" }
    No luck.  Any ideas?  Thanks!
      

     

  • Re: Resolving URL() in CSS

    05-04-2008, 12:48 PM
    • Loading...
    • TheDeathArt
    • Joined on 06-28-2006, 10:26 PM
    • Denmark
    • Posts 35
    Use the HTML element <base> with the attribute herf, ie. <base href="http://yoursite.com/"> or <base href="http://yoursite.com/rootfolder/">

    The CSS url paths is determind from the location of the css file and shouldn't be a issue. But you most likely want the <base> tag.
  • Re: Resolving URL() in CSS

    05-04-2008, 12:58 PM
    • Loading...
    • timtas
    • Joined on 11-05-2005, 10:23 AM
    • Posts 16
    I was mistaken.  Adding this to my main route works:
    Constraints = new RouteValueDictionary(new { id = "^(?!Content).*" })
    Testing error.  Duh.
     
Page 1 of 1 (3 items)