views:

37

answers:

3

I have a master page that has two content sections like this (left some parts out):

<head runat="server">
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder runat="server" ID="HeadContent" />
</head>

<body>
    <div id="content">
        <div id="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
    </div>
</body>

In one of my .aspx pages which references this master page, I supply the content like this (left some parts out):

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <% using (Html.BeginForm("Create", "Document", FormMethod.Post))
       { %>

       <p>
           <%: Html.LabelFor(m => m.Title) %>
           <%: Html.TextBoxFor(m => m.Title) %>
           <%: Html.ValidationMessageFor(m => m.Title) %>
       </p>

       <p>
            <input type="submit" class="t-button t-state-default" value="Create" />
       </p>

    <% } %>


</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

Yet the label created by the LabelFor chunk above does not get styled. In my CSS file, I have a rule to set the font globally and this is not applying - the font is defaulting instead.

Do I need to re-include all my CSS and Javascript in the 'Content2' section in the .aspx page? Isn't it sufficient to include them once in Site.Master?

+1  A: 

Have you included a stylesheet rule for <label>?

Use a DOM inspector (Firebug, etc) to see where the label style (or lack thereof) is coming from.

Phil Brown
+1  A: 

I must define stylesheet rule for <label>, like this:

label { margin:10px; color:blue; }
Rail
+1  A: 

You only need to include CSS and JavaScript references in the master page. The markup from both the master page and content pages are combined and sent as a single HTML document.

Your CSS probably doesn't match your markup properly so the styles aren't being applied correctly. You could add the CSS to your question for more assistance or use Firebug to inspect the source and styles.

AUSteve