1

I'm working on a Web Application in Visual Studio 2010. For some reason the CSS only works properly inside visual studio. I can see the CSS inside the design view of the page. When I view the page on localhost the CSS is not being applied. can anyone help me?

this is the code:

asp file:

</head>
    <body>
        <form id="form1" runat="server">
            <asp:Image ID="Image1" runat="server" ImageUrl="~/images/344704-5.jpg" CssClass="Image"/>
        </form>
    </body>
</html>

CSS file:

body
{
    background: #FFFF00;
    font: normal small Arial, Helvetica, sans-serif;
    color: #FFFFFF;
}


.Image
{
    left: 321px;
    position: relative;
    top: 2px;
    width: 282px;
    height: 187px;
}

EDIT: <link href="Styles/Site.css" type="text/css" rel="stylesheet"/>

what could be wrong?

thanks.

2
  • You should try: <link href="/Styles/Site.css" type="text/css" rel="stylesheet"/>
    – PeeHaa
    Jul 30, 2011 at 11:50
  • @PeeHaa: I tried, it not helped.
    – Ofir A.
    Jul 30, 2011 at 11:53

4 Answers 4

1

the problem was that I need to clear the browser cache every time that I run the ASP file. I don't know if it is how it suppose to be, but it works.

3
  • 1
    Depends on your browser settings. Generally, we turn off all caching at the browser during development to avoid this.
    – NotMe
    Jul 31, 2011 at 21:28
  • Oh my good god, it finally works, thanks @Ofir A.! Seriously, I spent about an hour trying to implement various forms of IE8 meta tag hacks, but clearing my cache did the trick. Jul 3, 2013 at 18:57
  • 1
    @Ian Campbell I'm glad that my efforts helped you.
    – Ofir A.
    Jul 3, 2013 at 19:03
1

Probably you don't have access to Site.css file.

Maybe an authenticated security web form is blocking the file, try to give access to this file.

0

I can't see anything wrong with the code that you have posted.

My guess would be that there is something wrong with how you include the CSS in the page, but I can't know as you have omitted that part of the code.

0
0

Open the source view of your page in development mode and look at the URL to the CSS file. The path to the file on the development server is probably wrong. Double check the folder structure on the development server - you can try paths like folder/stylesheet.css or /folder/stylesheet.css etc.

2
  • I don't have much experience, so I would appreciate if you could elaborate how exactly to do it. thanks.
    – Ofir A.
    Jul 30, 2011 at 11:51
  • Umm.. I don't remember exactly where to find the folder the developed site is running out of. Try looking in bin/debug? Assuming the image in your example works, one other thing you can try is putting the style sheet in your images directory: ~/images/stylesheet.css and linking to it from there. If that works then just create a styles directory in the same folder as images directory and use ~/style/stylesheet.css. Basically it's just a matter of tinkering with the folder structure/URLs until it works..
    – filip-fku
    Jul 30, 2011 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.