Lesson_08_masterpage
-
Upload
adnan-amin -
Category
Documents
-
view
223 -
download
0
Transcript of Lesson_08_masterpage
-
8/7/2019 Lesson_08_masterpage
1/13
WEB ENGINEERING-IIUSING ASP.NET
By
Adnan AminLecturer / Software Programmer
Information and Communication Technology(ICT Dept)
Lesson: 08
Topic: Master & Contents Pages
By: Adnan Amin (Lecturer/Software Programmer) 1
-
8/7/2019 Lesson_08_masterpage
2/13
Overview
Master Page
ContentPlaceHolder HTML Server Control. Contents pages
By: Adnan Amin (Lecturer/Software Programmer) 2
-
8/7/2019 Lesson_08_masterpage
3/13
New Pages in ASP.net
There are two New pages introduced in ASP.net:
Master page
Content Page
By: Adnan Amin (Lecturer/Software Programmer) 3
-
8/7/2019 Lesson_08_masterpage
4/13
The Master page
Master page is provides the page template
for the whole web site.
It can contain one or more layout contents.
It can place code in master pages of thecontents pages.
Contents pages take place in placeholder
location of the master page which willdefined by ContentPlaceHolder controls.
The extension of master page is *.master.
By: Adnan Amin (Lecturer/Software Programmer) 4
-
8/7/2019 Lesson_08_masterpage
5/13
2. Content page
The content page provides particular
contents.
At run time, the contents will be displayed
within ContentPlaceHolder controls. Each content page must be linked with aspecific master page.
The master page layout will displaysurrounding the content page.
By: Adnan Amin (Lecturer/Software Programmer) 5
-
8/7/2019 Lesson_08_masterpage
6/13
Adding New Master Page
Open new website.
Add new Item select Master Page
Design the master page.
By: Adnan Amin (Lecturer/Software Programmer) 6
-
8/7/2019 Lesson_08_masterpage
7/13
Creating a Content Page
Add New Item Select web form and click Add button. Select the MasterPage for your Content page.
At top of the page code, you will see: (if not then type)
By: Adnan Amin (Lecturer/Software Programmer) 7
-
8/7/2019 Lesson_08_masterpage
8/13
Converting a normal page to content
page Follow the following steps:1. Content page cannot contain any normal page markup.
1. No html tag (, ,etc)
2. Generally contain only Content Controls.
1. Generally contain only Content controls(ContentPlaceHolder Control) associated with masterpage.
3. Master page used the ContentPlaceHolderID property todetermine where the content goes.
4. Add Content control and type or insert the contents.
5. Remove page elements and stuff.
-
8/7/2019 Lesson_08_masterpage
9/13
Adding/Override Default Content(On Master Page) We can also add more than one
ContentPlaceHolder controls on master page. Content page also need not to supply all thecontent of the master page. So we can override
the contents of master page in content page.
By: Adnan Amin (Lecturer/Software Programmer) 9
-
8/7/2019 Lesson_08_masterpage
10/13
Adding Default Content
Open the Master page
Add ContentPlaceHolder Control from ToolBox onMaster page.
Add some master page Stuff in
ContentPlaceHolder (above one)
Run the content pages where the master page isused.
Definitely you will get more information on contentpages by adding second default content onmaster page.
By: Adnan Amin (Lecturer/Software Programmer) 10
-
8/7/2019 Lesson_08_masterpage
11/13
Override the Default contents
If we dont need the default contents of master
page on some of the content pages then we canoverride it.
Open the Content page and right click on
ContentPlaceHolder control then click onCreate Custom Contents. bring changes insource code.
If you need back the default contents then againright on ContentPlaceHolder then click onMove to Default Maters content option from the
menu in design of view of content page.
By: Adnan Amin (Lecturer/Software Programmer) 11
-
8/7/2019 Lesson_08_masterpage
12/13
Best Practice Creating Master Pages.
Usually developers use the tables to design
the layout for the master pages.
You can also use CSS positioning to get
the same effect. Or Place header , footer, navigation in tablecells.
By: Adnan Amin (Lecturer/Software Programmer) 12
-
8/7/2019 Lesson_08_masterpage
13/13
Assignment: Create the followinglayout.ADD HERE header
Menu 1 NewsUpdate
Menu 2
Menu 3
Menu 4
Image
Add HERE Footer
By: Adnan Amin (Lecturer/Software Programmer) 13