Skip Ribbon Commands
Skip to main content

Robin | zevenseas | SharePoint Blog

:

The zevenseas Community > Blogs > Robin | zevenseas | SharePoint Blog > Posts > Application Pages and choosing the right master page
March 30
Application Pages and choosing the right master page

In the past few months I’ve gained some experience in building custom application pages. And I wanted to share some things I’ve come across while building those pages.
First of all when provisioning these pages, you have two choices of folders to put them in.

  1. ADMIN folder, use this folder when your application pages should be accessed only via the Central Admin.
  2. LAYOUTS folder, use this folder when developing application pages that can be accessed by every web or site.

Next to those two folder options you also have the choice of which masterpage to use. When creating Application Pages that end up in the

  • ADMIN folder (12hive/Templates/ADMIN) attach the following masterpage:
<%@ Page Language="C#" MasterPageFile="~/_admin/admin.master" Inherits="Custom_Solution.Custom_Class" %>
  • LAYOUTS folder (12hive/Templates/LAYOUTS) attach one of the following masterpages:

<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Custom_Solution.Custom_Class" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/layouts.master" Inherits="Custom_Solution.Custom_Class" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/simple.master" Inherits="Custom_Solution.Custom_Class" %>

Below is a finding of some weird behavior I came across when I accidently was referring to a masterpage that was in another folder than the page.

  • Page location: ADMIN folder
    Referenced masterpage: ~/layouts/simple.master
    • Symptom : Simple page with some TextBoxes that were loaded with data from a database and at the bottom a button to save changes. When I clicked the button I immediately got a “The security validation for this page is invalid” error.
    • Solution : Change the masterpage to ~/_admin/admin.master or to ~/_layouts/application.master

So I reckon it’s best to use the masterpages that you can find in the corresponding folder. Just to avoid the troubles you might  get ;)

Comments

Jeroen Ritmeijer

good stuff as very few developers take this into account.

You will also find that if you use the wrong masterpage, e.g. Layouts.master in an Admin folder then your breadcrumbs (particularly the highlighted tab) will not work properly.
System Account on 30/03/2009 08:03

Robin

Thanks Jeroen.. and indeed navigation is something to take into account when choosing the proper masterpage as well.
System Account on 31/03/2009 02:28

BobC

Is there a way to use SPD to design custom app pages visually?
System Account on 24/04/2009 12:35

Robin

Hi Bob, I have no idea of you can use SPD since I rarely use it. Would be a good one to investigate ;)
System Account on 25/04/2009 04:47
 

 Statistics

 
Views: 1919
Comments: 4
Tags:
Published:1145 Days Ago