views:

684

answers:

3

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"&gt;
<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!

A: 

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

Strelok
This should not be explicitly required. The Title attribute of the Page directive is supposed to fill it in.
BlackMael
Nah, you're barking up the wrong tree there. The Title attribute of the page directive should be an entire alternative to the <title> element. In your example, you'll get a 'Title not defined'-type error.
CJM
yeah ... forgot about that... and I write ASP.NET all day :) We haven't touched our masters for months though :) To me a web page is just a bunch of controls in content placeholders :)
Strelok
+1  A: 

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

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

Oops.

CJM
Doh! I'd checked one of my own apps and didn't spot the missing runAt server... sigh...
BlackMael
CJM
Hmmm... voted down - I wonder why... People, eh?!
CJM
I think folks vote things down when you post a new item instead of using the "add comment" feature against your original post. This happened to me the other day :(
deadbug
But this was a valid answer. The runAt attribute was missing..
BlackMael
Indeed - it was an answer to the question rather than an edit to the question.... Not to worry - it matters little. :)
CJM
A: 

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>