Share via


'How do I' create a layouts page

Following the lead of Sara Ford, I think I want to do a 'How do I' piece for SharePoint developers. I don't know how long this will last, but this is the first post.

First off, layout pages require the following directives. Try as I may, I have never been able to get around whatever permission demand is blocking layout pages from inheriting a specific class.

<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Page language="C#" MasterPageFile="~/_layouts/application.master" inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

The files must be placed in the %12-hive%\Template\Layouts directory-I usually create a custom folder underneath based on my specific feature to separate my custom code from SharePoint code. Incidentally, I recommend putting stylesheets, JavaScripts, and generic HTTP handlers here as well (the HttpHandler does allow you to create a code behind compile and deploy to this directory, which is cool). On your layouts pages you can add any web parts and custom controls you wish, you just have to add them manually as you don't have web part zones or personalization.

Note: By putting pages in the layouts directory, you may be breaching your security for the application as layouts pages are available to any authenticated user (not in a publishing scenario, though). Ensure that your pages are secured using controls such as the SPSecurityTrimmedControl.

Comments