Wow, that's a lot of new stuff, right? The new concepts introduced in this chapter will totally change the way you handle data within ASP.NET. Thanks to Data Source controls, it's so much simpler now to connect a page with a database. One of the biggest benefits is that you can easily build your own providers to access your custom data sources as well.
The Master Pages functionality goes by many
The 1.0 and 1.1 versions of ASP.NET didn't offer the Master Pages functionality. That was a good reason for many developers to implement their own approaches. These approaches went from the static output of HTML tags to the implementation of
With version 2.0, ASP.NET offers its own and fully integrated support for Master Pages for the first time. You develop one or several layouts as Master Pages and allocate them to single Content Pages. In combination with VS .NET, you can now design the Content Pages visually within the Master Pages context and fill one or several defined placeholders.
Please create a new and empty web site before you start with a new Master Page. Then choose Add New Item from the Website menu and establish a new element from the type MasterPage with the
In the result, you get a new page that includes a control of type ContentPlaceHolder. This is a regular control, which means that you can integrate it as usual into the HTML layout of the page. Now I would like to show you a table to which I've added some text. I also placed the control in one of the
Figure 4-1: Design your site any way you want!
Have a look at the source code of the page in Listing 4-1 and you can see that the structure of the Master Page is compatible with a normal web site. The ContentPlaceHolder control is positioned just like a normal server control. There is still one difference, however: the
directive. In this case, it
Listing 4-1: The Master Page Source Code
<%@ master language="C#" %> <script runat="server"> </script> <html> <head runat="server"> <title>Untitled Page</title> </head> <body> <form runat="server"> <table id="Table1" cellspacing="1"
cellpadding="1" width="100%" border="1"> <tr> <td colspan="2"> <h1>My Little Company</h1> </td> </tr> <tr> <td>Navigation?</td> <td> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> </body> </html>