How to use background css for an image not in the Content or Resource folder


Tags: css,asp.net-mvc-4,razor

Problem :

I have a background image for an input, just using inline styling because it would be changed with javascript later:

<input type="text" style="background: url('??') no-repeat;" />

What do I put as the url? This is the directory structure:

Directory Structure

(Where above Views is just the root project folder)

The input is on MyPage. I've tried using /Views/1/2/3/Content/images/somePic.jpg, but it apparently could not be found, which is confusing as it had worked before when I just had it in Root/Resources/somePic.jpg and linked it as Resources/somePic.jpg.

I don't have a choice over which directory this image is in. How do I link it properly with this setup?



Solution :

Ahhh nevermind, the problem apparently lay in something completely irrelevant. There was a line in Web.config that essentially said to give a 404 error for all content in the Views folder. The fix was to just add an exception for the Content folder. The path I've been using did work; it was just a permissions problem.


    CSS Howto..

    How can I make a span stretch the available space between to other spans?

    How to use :hover css when mouse is down

    how to update a css class dynamically onclick a dropdown jquery

    How do you create a scrollbar that recognizes scrolling only for the current topmost container using css?

    PHP: How to add a CSS text-align property to an already present inline style attribute of an element using simple_html_dom parser?

    How to make a table scrollable with fixed header?

    How to insert the number into the bottom right of each page by TWIG and CSS

    How To Isolate a div from public CSS styles?

    How to line up images in a horizontal row with CSS?

    HTML+CSS: How to add shadow (as image) to image?

    How to fade-in and fade-out background-image with CSS transition?

    How to have elements copy other element's auto height css?

    How to make rounded corner cut-out using CSS?

    How can I hide a div completely from HTML DOM?

    html5, how to style Figure differently for different case?

    How to add different CSS3 hover transitions on hover out with CSS

    How do you style an android app?

    How to make button that changes grid dimensions using JS?

    With CSS, how would I align this banner and navigation menu to XHTML 1.0 Strict specifications?

    How to make a img flicker using css(should work in all browsers)

    How do I let the DOM know about new elements created on the fly?

    How to check if all CSS files have been downloaded to insert HTML using JavaScript?

    How to fade background images (from CSS) in and out with jquery

    How to prevent divs from overlapping?

    How to Detect css style by iPhone/iPad

    How to set content to -webkit-slider-thumb

    How to Center Rotated text with CSS

    How to make CSS URL background images show up in localhost?

    How to reverse jQuery css styling?

    how to custmize font awasome icons using cheat sheet in css?