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>
We ran into this exact issue on one of our sites.
The immediate fix was to reset the title in the master page codebehind page_load method.
Apparently when the ajax call occurs, it is rerunning the master page. This was causing our title to disappear.
For example:
protected void Page_Load(object sender, EventArgs e) {
this.Page.Title = "whatever title you have...";
}
A better fix is to drop the MS updatepanel crap and start using JSON / jQuery where you actually have some decent control over the calls.
Are you opposed to using the Title property of the Content Page?
<%@ Page Title="Your Page Title" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPages/...
You can also access this programmatically in the page load...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With