| Simple Master Pages |
Not much to report here. Creating a MasterPage is dirt simple
- Right-click Add-New Item and select MasterPage
- Add your asp:ContentPlaceHolder controls to the page for any content areas
I found it makes sense to add your default HTML to the content placeholder. That way
your page can either accept the default or override by adding a asp:content control that
uses your placeholder
|
<asp:ContentPlaceHolder ID="pageHeaderContentPlaceholder" Runat="server">
<table bgcolor="#e7e6e6">
<tr>
<td><a href="http:\\www.monster.com">Monster.com</a> </td>
<td> </td>
<td><a href="http:\\network.monster.com">Network.Monster.com</a></td>
<td> </td>
<td><a href="http:\\my.monster.com">My.monster.com</a></td>
</tr>
</table>
</asp:ContentPlaceHolder>
|
| Simple User Control with Shared Partial Class |
Much like the master pages this is fairly simple
- Right-click Add-New Item and select UserControl
- Check the Create code in separate file checkbox
|
If you don't create the code in a seperate file and decide you want to later
Then it is a little more convoluted:
At first I tried to create a class and name it the same as what it would have been named had I used VS to create the code beside.
However when I went to compile it complained that the class already existed. Instead I created my class, marked it as partial and set the
.ascx page attributes: ClassName and CompileWith to be the new class name.
You will have to put the class into the project hierarchy not into the code folder.
That did the trick. The only thing I don't like is that the new class doesn't show up underneath it's parent ascx file like it would had I used the dialog to create it. |
| Nested Master Pages |
Nesting Master pages provides a centralized way to create a consistent look and feel
- Right-click Add-New Item and select MasterPage
- Select create code in separate file
- Add tag: MasterPageFile="your master page name" to your page directive
|
Nested Master pages aren't currently supported in the IDE so you have to do all your work in the code view.
You can't 'inherit' a ContentPlaceHolder from a nested parent master page. So if you have a placeholder that you want to be able
to use in your actual content page you have to add a content tag and inside of it add another placeholder:
<asp:Content ContentPlaceHolderID="pageBodyContentPlaceHolder" Runat="server">
<asp:ContentPlaceHolder ID="pageBodyOverride" Runat="Server"></asp:ContentPlaceHolder>
</asp:Content>
Then the pageBodyOverride content placeholder will be available in your page. You use it by adding:
<asp:Content ContentPlaceHolderID="pageBodyOverride" Runat="Server">
whatever mark up you want
</asp:Content>
|