Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS not loading on deployment (Newbie here, apologize in advance)

Status
Not open for further replies.

xzibited2

Programmer
Dec 11, 2009
9
US
Guys - I've deployed a test project onto one of our web servers, and it doesn't appear that the CSS file is taking correctly. The page loads fine, but the styles aren't there. It looked fine in debug. Any thoughts on what's going on? I'm sure there is an easy solution, but I'm very new to the ASP.NET world.
 
Hi,
Can you post the code from the main page showing how you are specifing the CSS?

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Turkbear, here is the reference in the site.master file:

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

 
Have a look at the rendered HTML and you should see where the problem is. My guess is that the ~ isn't providing the path to the root application as the code you hagve pasted above is just HTML and therefore the server won't know about it.

If that is the case, you could add runat="server" to the above control or you can use a relative or absolute path to the css file.

Mark,

Darlington Web Design[tab]|[tab]Experts, Information, Ideas & Knowledge[tab]|[tab]ASP.NET Tips & Tricks
 
ca8msm -- Rendered shows the path correctly:

---
<link href='/styles/site.css' type='text/css' rel='stylesheet'/>
----

I changed the way .master calls the CSS form on the recommendation of someone else, but either way it still isn't working. Here is the entire .master file:

----

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.master.vb" Inherits="WebApplication1.Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<html xmlns=" xml:lang="en">
<head runat="server">
<title>Test</title>

<%= string.Format("<link href='{0}' type='text/css' rel='stylesheet'/>", ResolveUrl("styles\site.css")) %>




<asp:ContentPlaceHolder ID="HeadContent" runat='server'>
</asp:ContentPlaceHolder>
</head>
<body>
<form runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
Test
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">

</div>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top