3 Replies - 2266 Views - Last Post: 26 October 2011 - 11:47 AM

#1 litedrive  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 102
  • Joined: 30-September 10

ASP.Net and CSS: Refusal to display styling.

Posted 25 October 2011 - 10:50 PM

I'm currently using ASP.Net MVC3 Razor, albeit I'm having a bit of a problem: the css refuses to display, regardless of what I do with it. I've validated it, and it looks fine. It also builds, and runs without any errors. The problem is that, no matter what I try, the CSS won't display at all.

Here's my Content1 File which imports a base template:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";   
}

<h1> Structured Content </h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</p>


The CSS:

h1 {
    border-bottom: 3px solid #cc9900;
    font: 2.75em/1.75em arial, helvetica, sans-serif;
    color: #996600;
    background:#000;
}

ul {
    list-style-type:none;
}

body {
margin: 0;
padding: 1em;
background-color:#ffffff;
font: 75%/1.75em "Trebuchet MS", Verdana, sans-serif;
color: #006600;   
}

#list {
    margin: 1em 0 7em -3em;
    padding: 1em 0 0 0;
    background-color: #fff;
    color: #996600;
    width: 25%;
    float: left;    
}

#header, #footer {
    margin: 0;
    padding: 0;
    color: #996600;    
}





And the template file...

<!DOCTYPE html>
<html>
    <head>
        <title> Structured Content </title>
        <link rel="stylesheet" type="text/css" href="@Href("~/Views/Shared/Styles/Site.css")" />
    </head>
    <body>
        @RenderPage("_Header2.cshtml")
        <div id="main">
            @RenderBody()
        </div>
        @RenderPage("_Footer.cshtml")
    </body>
</html>




Is there anything which I'm doing wrong? I'm on literally 46 hours without sleep, so if I miss something which seemed pretty obvious then that's why.

Is This A Good Question/Topic? 0
  • +

Replies To: ASP.Net and CSS: Refusal to display styling.

#2 FrankC  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 45
  • Joined: 06-October 11

Re: ASP.Net and CSS: Refusal to display styling.

Posted 26 October 2011 - 10:59 AM

I only know how to work with PHP servers, but in PHP we have normal tags/URL's in the head. So an external style sheet would simply be linked like this:
<link rel="stylesheet" type="text/css" href="../Views/Shared/Styles/Site.css" />


assuming that the folder Views is one folder level up from the HTML file.
Was This Post Helpful? 0
  • +
  • -

#3 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 207
  • View blog
  • Posts: 1,599
  • Joined: 12-January 10

Re: ASP.Net and CSS: Refusal to display styling.

Posted 26 October 2011 - 11:07 AM

we use externals like this at work:

<LINK rel="stylesheet" type="text/css" href="<%=stylesheet%>">

Was This Post Helpful? 0
  • +
  • -

#4 litedrive  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 102
  • Joined: 30-September 10

Re: ASP.Net and CSS: Refusal to display styling.

Posted 26 October 2011 - 11:47 AM

Well, I'm using the Razor engine for this, so those ASP.net tags won't work. And I tried using just a simple "href='path/to/stylesheet'" tag, and that didn't work either.

Could someone move this to the asp.net section, possibly?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1