Question

This is what I have in the aspx page:

<head runat="server">
    <title>Website - <asp:ContentPlaceHolder ID="HeadContent" runat="server" /></title>
</head>

This is what's in the view:

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

For some reason, this HTML is generated:

<title>Homepage</title>

The 'Website - ' part is getting removed. Anybody know how I can fix this?

Was it helpful?

Solution

Phil Haack has an explanation of this issue (and a work-around) at http://haacked.com/archive/2009/04/03/tipjar-title-tags-and-master-pages.aspx . The work-around is that you use an asp:LiteralControl for the static part of your page title.

OTHER TIPS

could you do something like this?

<head runat="server">
    <asp:ContentPlaceHolder ID="HeadContent" runat="server"><title>Website</title></asp:ContentPlaceHolder >
</head>

and then override the whole title string in your view?

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title>Homepage</title>
</asp:Content>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top