I have just noticed recently that my page title will reset to the standard ‘Untitled Page’ after I perform an asyncpostback from inside my UpdatePanel in the main page. The title will not be lost during a postback from inside the master page (such as when I click on the search box button inside the master page).
I assumed that by using a different contentplaceholder specifically for setting the document title I was going to avoid issues like this, but apparently I was wrong. Is there something else I am missing other than having to explicitly set the title in the code-behind of the ASPX page (which I was hoping to avoid with the way it was setup below)?
Here is the basic gist of my page which is calling the Master Page (master page code below)
<asp:Content ID='Content1' ContentPlaceHolderID='title' Runat='Server'> Page Title </asp:Content> <asp:Content ID='Content2' ContentPlaceHolderID='head' Runat='Server'> <script type='text/javascript'> //random javascript validators </script> </asp:Content> <asp:Content ID='Content3' ContentPlaceHolderID='content' Runat='Server'> <div class='title'> Account Management </div> <asp:UpdatePanel ID='UpdatePanel1' runat='server'> <ContentTemplate> //Username + Password Set Form </ContentTemplate> </asp:UpdatePanel> </asp:Content>
This is the of the Master Page. The ASP.NET AJAX ScriptManager is placed first thing after the <form> tag in the body.
<head id='Head1' runat='server'> <title> <asp:ContentPlaceHolder id='title' runat='server'> </asp:ContentPlaceHolder> </title> //Stylesheet references <script type='text/javascript'> //Random javascript functions </script> <asp:ContentPlaceHolder id='head' runat='server'> </asp:ContentPlaceHolder> </head>
Are you opposed to using the Title property of the Content Page?
You can also access this programmatically in the page load…