26 April 2011

interview questions: Asp.net Master Pages

Topic : Asp.net Master Pages

Faculty Name : Keerthy C

Question - Define Multiple Master Page.

Answer - In ASP.NET, you can have multiple master pages each for a different purpose. You can provide users several layout options using Multiple Master Page. You can define Master Page at multiple places in the web application.

You can specify page-level using the @Page directive.
You can specify using the Web.config.

Remember that the definition closest to the user wins that means page-level definition supersedes site-level definition.

Faculty Name : Pinky Bhadran

Q.
How to create Nested ASP.NET Master Page ?

Master pages can be nested, with one master page referencing another
as its master. Nested master pages allow you to create componentized
master pages. For example, a large site might contain an overall
master page that defines the look of the site. Different site content
partners can then define their own child master pages that reference
the site master and that in turn define the look for that partner's
content.

A child master page has the file name extension .master, as with any
master page. The child master page typically contains content controls
that are mapped to content placeholders on the parent master page. In
this respect, the child master page is laid out like any content page.
However, the child master page also has content placeholders of its
own to display content supplied by its own child pages. The following
three page listings show a simple nested master page configuration.

This is the parent master

Faculty Name : Saravana Kumar

(Q)What are the advantages of using Master Pages?
(Ans)
1. They allow you to centralize the common functionality of your pages so that you can make updates in just one place.
2. They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.
3. They give you fine-grained control over the layout of the final page by allowing you to control
how the placeholder controls are rendered.
4. They provide an object model that allows you to customize the master page from individual
content pages.

Faculty Name : Saravana Kumar

(Q)What are the 3 levels at which content pages can be attached to Master Page?
(Ans)
At the page level - You can use a page directive in each content page to bind it to a master page

At the application level - By making a setting in the pages element of the application's configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page.

At the folder level - This strategy is like binding at the application level, except that you make the setting in a Web.config file in one folder only. The master-page bindings then apply to the ASP.NET pages in that folder.

Faculty Name : Majesh

Q) Difference between MasterPage and WebUserControl

Ans)
A master page is a template for other pages, which shares design and functionality with other pages. The master page provide a content place holder for other pages.

Web user control is a unit of functionality, which incorporate into parent page. it does not give a template design and functionality as master page gives. .NET provide .ascx extension for user control.

No comments:

Post a Comment