I have an ASP.NET application that uses a master page configuration. What I’d like to do is two things.
-
How can I programmically set the title in the child page (as in the text in the
<title></title>tags? And, -
If the child page does not set the title, I’d like the master page to automatically detect this and set a default title.
Any help would be appreciated.
you can have your pages inherit from a custom page
Then, in your MasterPage’s Page_Load, do ( can’t remember if MasterPage.Title exists or if you’ll have to do Page.Title, which will work since both objects are Page objects):
Then, when you create a Page, for instance a CustomerManager page:
This way, your MasterPage isn’t 100% tied to using CustomPage (creating normal Pages won’t throw an error). And, if you use CustomPage objects, you’re all set!