For an introduction to master pages, see "Master Pages In ASP. To make use of master pages, we first need to understand how master pages work. NET web form using a master page, the content page (.aspx) and master page (.master) merge their content together to produce a single page.Many of the tips and traps covered later in this article revolve around understanding the magic behind master pages. Let’s say we are using the following, simple master page.
I have inherited an project, which has some datasets in it.
I find that when I edit datasets with new SQL, adding columns, tableadapters etc, that the class is not regenerated, and therefore I can't access them in code.
The master page is in control - giving orders and rearranging controls.
However, by the time the Init event fires the master page becomes just another child control inside the page.
When it comes time for the master page to do its job, the master page replaces the page’s children with itself.
The master page’s next step is to look for Content controls in the controls formerly associated with the page.
Let’s also write a simple web form to use our master page.
The web form contains a single Content control, which in turn is the proud parent of a Label.
We don’t want to duplicate this code in every webform.
A better idea is to create a base class in a class library project, or in the App_Code directory. For web forms with inline code, we just need to change the Inherits attribute of the @ Page directive. If a specific page doesn’t want it’s master page set, it can choose not to derive from Base Page.
The master page contains some common elements, like a head tag.