简体   繁体   中英

Title (in ASP.NET @ Page directive) not rendering in web page

I was intending on use the Title attribute in the @Page directive to customise each pages title, but it simply doesn't appear to do anything.

The site uses master pages - I don't know if that is a consideration.

Master Page snippet:

<%@ Master Language="VB" CodeFile="brightnorth.master.vb" Inherits="brightnorth" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="/css/style.css" />
</head>
<body>
etc....

Page snippet (from http://www.brightnorth.com/about/aboutus.aspx ):

<%@ Page Language="VB" MasterPageFile="~/brightnorth.master" AutoEventWireup="false" CodeFile="aboutus.aspx.vb" Inherits="about_aboutus" Title="Brightnorth.com: About Us" %>

What is more, if I run the page through the validator , it complains about...

end tag for "head" which is not finished

..whereas the the tag is present in the source code.

I've already got a workaround in place, but it's annoying the hell out of me, so I'm determined to find a resolution!

Oops... A basic error! [aren't they always?]

Anyone spot a missing runat="server" in the element?

Oops.

You've got to use the HTML tag as well :)

In your master page, inside the head tag you should have:

<title><%=Title%></title>

http://www.w3schools.com/TAGS/tag_title.asp

This is what you need to have, in the masterpage, if the title is coming from the page directive:

<head runat="server">
<title><%=Page.Title%></title>
</head>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM