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 do I make a certain text style larger?

    How can I align my search button to the right?

    How to horizontally center text in bootstrap button?

    How to expand toggle sidebar more

    css how to only make bold fonts for first
      set

    How can I change the entire background color of a page?

    How to use CSS' “rotateX()” with jQuery's animate() on multiple elements with delay

    how to tint image in div when clicked for 0.5 seconds

    How to use CSS with javascript

    How to make scrollbars appear when DIV doesn't have enough room but keep DIV centered?

    How to have a logo in the middle of two menu lists?

    myFlowPanel has many childFlowPanels, so how to create the same margin for all childFlowPanels without using marginTop on childFlowPanels (GWT)?

    How to create responsive square

    How do I make an element scale down to nothing using a CSS transition on the iPhone?

    How do i apply fadein and fadeout effect for this?

    How to apply background image to a xhtml file? [closed]

    How can I remove the spacing above a block element in CSS?

    How to apply multiple CSS selectors to a paticular div?

    How to make the height of the div take all the space?

    How to create popups in css /Javascript?

    How to add and remove a current state to a link when another is clicked using jQuery

    How to make separating lines/borders in a table disappear with CSS?

    website div won't stretch from left to right, how do you fix css?

    How to increase a CSS value by the value of a JS variable?

    How to disable temporary cursor with javascript?

    html web shows header only in mobile view

    How do I control the spacing between my child links in my CSS driven menu dropdown?

    How do I implement a MailChimp API form embed?

    How to show/hide content on click with CSS

    How CSS property “opacity” renders in browsers (IE, Chrome, Firefox, Opera)?