ASP.NET Master Page Tutorial Part-11 (Adding Content Region/ContentPlaceholder)

In previous post ASP.NET Master Page Tutorial Part-10 (Moving Css To External Css Files) i told you how to move all css code to external files and how to create and use it in our ASP.NET website master page.
A MasterPage can have multiple content place holders. In visual studio we can add a new content placeholder in masterpage, simply drag and drop the ContentPlaceholder control from the Toolbox. You can also add a ContentPlaceholder declaratively in the HTML view. ContentPlaceholders, like any other Web control.

A Content Region (ContentPlaceHolder) control defines a relative region for content in a master page, and renders all text, markup, and server controls from a related Content control found in a content page.


Here i show you how to add content region in ASP.NET website in Microsoft Expression web.I will create two Content Regions in the MasterPage,one for the main content on the middle of master page all other at the bottom.

<br />Adding content region (content place holder) in asp.net using expression web

Right click on div#maincontent then click on "Manage Microsoft Asp.net content Region".

Adding content region (content place holder) in asp.net using expression web

Enter the Region name "maincontant" because its a main part of page.

Adding content region (content place holder) in asp.net using expression web

It will automatically apply on selected div.See the Content Region (Content Place Holder) is added.

Adding content region (content place holder) in asp.net using expression web

Agian Right click on div#contentbootom then click on "Manage Microsoft Asp.net content Region".

Adding content region (content place holder) in asp.net using expression web

Enter the Region name "contentbottom".

Adding content region (content place holder) in asp.net using expression web

See another Content Region (Content Place Holder) is added.

Adding content region (content place holder) in asp.net using expression web

When all was said an done, I ended up with the MasterPage shown in the screenshot below:

Adding content region (content place holder) in asp.net using expression web

Adding Masterpage Toolbar.

Now go to View > Toolbox > Masterpage..

Adding content region (content place holder) in asp.net using expression web

Masterpage Toolbar.

Adding content region (content place holder) in asp.net using expression web

Just drag n drop this masterpage tool bar to upper tool bar.
Master page tool bar is used to manage content regions for easily.

Adding content region (content place holder) in asp.net using expression web

Save this page.Once a MasterPage has been created we are ready to create aspx pages from this master page.all of the pages of this Asp.net site is made by this master page.
Next part i will show you in another Tutorial.

Share this

Related Posts

There was an error in this gadget