Reputation: 20004
I have a master page and in its page load event I am appending to the page title:
Title = Title + " MyWebsite";
Then in a page that uses the previous master page:
Title = "Home";
What ends up rendering is the value from the master page. A closer look at the debugger shows that it evaluates the Title attribute in my content page, but still says it's an empty string (even though I explicitly have a value set to it.)
Note: Content pages get evaluated before master pages ( I didn't realize this).
Upvotes: 1
Views: 1244
Reputation: 52241
You need to set page title in Page_PreInit
event
protected void Page_PreInit(object sender, EventArgs e)
{
//set here....
}
Upvotes: 3
Reputation: 4968
I have used the following... and it works as expected.
this.Page.Title = this.Page.Title + " Master Title";
Upvotes: 0