问题
my goal is to find a way to update the title of the page at the very last moment before it get created
I have a master page and a content place holder that always contain a page with a specific property.
that property can be updated anywhere in the code but I want the final value of that tag to be the html title
is the prerender event of that page the best place to set the title?
回答1:
PreRender
is one place where you could set the title, another -later- is PreRenderComplete
:
protected void Page_Init(object sender, EventArgs e)
{
this.PreRenderComplete += Page_PreRenderComplete;
this.SaveStateComplete += Page_SaveStateComplete;
}
Edit: Just noticed that you can even use SaveStateComplete
event, that should be latest place where you could change the title:
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
Page.Title = "late title";
}
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
Page.Title = "very late title";
}

Some additional informations about page-title in masterpages and Site Map Data:
Dynamically Setting the Page's Title in ASP.NET 2.0
来源:https://stackoverflow.com/questions/10525088/can-someone-confirm-my-understanding-about-asp-net-live-cycle