Wednesday, 14 August 2013

Child Page Doesn't Pick Up Styles From Master

Child Page Doesn't Pick Up Styles From Master

I can't get my child page to pick up styles defined in my master. Here is
what I did:
I created a stylesheet Main.css in the root of my app
body {
background-color:red;
}
I created a Master Page Site.Master in the root of my web application
<%@ Master Language="VB" AutoEventWireup="false"
CodeBehind="Site.master.vb" Inherits="WebApplication1.Site" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
<link href="Main.css" rel="stylesheet" />
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
Master Page`
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
This shows up with a red background fine in the designer
I created a child page WebForm.aspx in the root of my app
<%@ Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="~/Site.Master" CodeBehind="WebForm1.aspx.vb"
Inherits="WebApplication1.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
Child Page Contents
</asp:Content>
But this doesn't show a red background either in the designer or at
runtime. When I view source there is no css declaration in the file, yet
it is picking up the master page because it displays "Master Page Child
Page Contents"

No comments:

Post a Comment