有人可以证实我对asp.net现场循环的理解?

问题描述:

我的目标是找到一种方法,在最后时刻更新页面的标题获得创建之前

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.

这是属性可在code随时随地更新,但我想该标记的最终值是HTML标题

that property can be updated anywhere in the code but I want the final value of that tag to be the html title

是页面的prerender事件来设置标题的最佳地点?

is the prerender event of that page the best place to set the title?

preRender 终止的有一个的地方,你可以设置标题另一个-later-是 preRenderComplete

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;
}

修改:只注意到你甚至可以用 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";
}

有关网页标题一些额外的信息在masterpages和站点地图数据:

Some additional informations about page-title in masterpages and Site Map Data:

动态设置页面的标题在ASP.NET 2.0