The Daily Insight
general /

What is a @master page in ASP NET?

Master Pages A master page is an ASP.NET file with the extension.master (for example, MySite.master) with a predefined layout that can include static text, HTML elements, and server controls. The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary.aspx pages.

How do I make a URL relative to the master page?

For example, you might put an Image control on a master page and set its ImageUrl property to be relative to the master page. At run time, ASP.NET will modify the URL so that it resolves correctly in the context of the content page.

What are server control properties in ASP NET?

In practical terms, ASP.NET server control properties that are commonly used to reference external resources are marked in this way. ASP.NET cannot modify URLs on elements that are not server controls. For example, if you use an img element on a master page and set its src attribute to a URL, ASP.NET will not modify the URL.

What elements can I use as part of the master page?

You can use any HTML and any ASP.NET elements as part of your master page. In addition to static text and controls that will appear on all pages, the master page also includes one or more ContentPlaceHolder controls.

What is the default title of the master page in Visual Studio?

By default, Visual Studio sets the element in the master page to “Untitled Page”. Similarly, new ASP.NET pages have their set to “Untitled Page”, too.

How do I find the master page of a content page?

When rendering a content page, the ASP.NET engine must fuse the page’s Content controls with its master page’s ContentPlaceHolder controls. The ASP.NET engine determines the content page’s master page from the @Page directive’s MasterPageFile attribute. As the above markup shows, this content page is bound to ~/Site.master.

What is an example of a master page?

For example, the following master-page directive includes the name of a code-behind file, and assigns a class name to the master page. In addition to the @ Master directive, the master page also contains all of the top-level HTML elements for a page, such as html, head, and form.