According to a few sources (including this one) when using a master page the page’s Load happens before the master page’s Load.
When I assign Page.Title a value in the page’s Load it works.
If I write Page.Title += "J" in the master page’s Load the title becomes J, regardless if a value was previously assigned.
In all cases, when I Response.Write(Page.Title) later on in the master page’s Load it’s empty.
What am I missing out here?
EDIT (some code):
default.aspx
Page.Title = "Title";
Master page
Page.Title += " - More title";
.
.
.
Response.Write("TITLE: " + Page.Title);
I get TITLE: in the window and - More title in the browser header.
EDIT (some debugging):
I added the following to my aspx and to the master page:
protected void Page_Init(object sender, EventArgs e)
{
Response.Write("<!--DEBUG-" + (debug_counter++) + "- TITLE: " + Page.Title + "-->\r\n");
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
Response.Write("<!--DEBUG-" + (debug_counter++) + "- TITLE: " + Page.Title + "-->\r\n");
}
protected void Page_Render(object sender, EventArgs e)
{
Response.Write("<!--DEBUG-" + (debug_counter++) + "- TITLE: " + Page.Title + "-->\r\n");
}
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
Response.Write("<!--DEBUG-" + (debug_counter++) + "- TITLE: " + Page.Title + "-->\r\n");
}
Plus a few similar lines throughout the Load function of both. They all come out blank.
I ended up using the
Page.Header.Titleinstead. It works.From here I understood they’re supposed to be the same. Apparently not.