I need to set the title of a page dynamically, and so I use code similar to the following:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="~/about.aspx.cs" Inherits="Default" %>
<%@ Register Assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>
<%@ MasterType VirtualPath="MasterPage.master" %>
<%@ OutputCache Duration="43200" VaryByParam="*" Location="Server" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title><%=pageTitle%></title>
</asp:Content>
But this generates duplicate title tags. Is there any way I can get around this? Thanks.
EDIT: Following from the suggestions below, I now have the following in my MasterPage:
<head id="Head1" runat="server">
<title>Default Title</title>
...
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
and the following in my primary page:
this.Title="xxx";
but I'm not getting any title (neither "Default Title" nor "xxx").
EDIT: Nevermind. Got it working using that method.