03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Consistent Page Layout with Master Pages x 211<br />

3. Add the follow<strong>in</strong>g highlighted code between the tags of the master page, replac<strong>in</strong>g the<br />

tags <strong>and</strong> the ContentPlaceHolder that VS added for you when you created the master<br />

page. Note that this is almost the same code you added to Default.aspx <strong>in</strong> Chapter 3, except for<br />

the element <strong>and</strong> the element with<strong>in</strong> the Header . The <br />

element takes the user back to the homepage, <strong>and</strong> will be styled later.<br />

<br />

<br />

Header Goes Here<br />

Menu Goes Here<br />

<br />

<br />

<br />

<br />

Sidebar Goes Here<br />

Footer Goes Here<br />

<br />

<br />

Make sure that you have the ContentPlaceHolder with<strong>in</strong> the Ma<strong>in</strong>Content tags. You<br />

can drag one from the Toolbox onto the page or enter the code directly, us<strong>in</strong>g IntelliSense’s helpful<br />

h<strong>in</strong>ts. In both cases you should give the control an ID of cpMa<strong>in</strong>Content.<br />

4. Next, switch the master page <strong>in</strong>to Design View <strong>and</strong> then drag Styles.css from the Styles folder<br />

<strong>in</strong> the Solution Explorer onto the master page. As soon as you drop the file, VS updates the Design<br />

View <strong>and</strong> shows the layout for the site that you created <strong>in</strong> Chapter 3. If the design doesn’t change,<br />

switch to Markup View <strong>and</strong> ensure there’s a tag <strong>in</strong> the head of the page po<strong>in</strong>t<strong>in</strong>g to your<br />

CSS file:<br />

<br />

<br />

<br />

<br />

The page should now look like Figure 6-2 <strong>in</strong> Design View.<br />

FIGURE 6-2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!