Blogroll

Friday, August 22, 2008

Determining the Site Template used on a SharePoint site

I just recently responded to a post in one the MSDN SharePoint forums where a user was asking how he could determine what templates where being used by his sites. I didn't really feel like having him look at the database, so I wrote a simple application page that exposes the WebTemplate and WebTemplateID properties of the SPWeb object. Here is what the code looks like:

<%@ 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" %><%@ Import Namespace="Microsoft.SharePoint" %>

<%@ 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" %> <%@ Import Namespace="Microsoft.SharePoint" %>
<script runat="server"> protected override void OnLoad(EventArgs e){ SPSecurity.RunWithElevatedPrivileges(delegate() { SPWeb thisWeb = this.Web;
lblWebTempalte.Text = thisWeb.WebTemplate; lblWebTemplateID.Text = thisWeb.WebTemplateId.ToString(); }); } </script> <asp:Content ID="Main" runat="server" contentplaceholderid="PlaceHolderMain" > <p> Web Template: <asp:Label ID="lblWebTempalte" runat="server" /> </p> Web Template ID: <asp:Label ID="lblWebTemplateID" runat="server" /> </asp:Content>
<asp:Content ID="PageTitle" runat="server" contentplaceholderid="PlaceHolderPageTitle" > Site Template Information </asp:Content>
<asp:Content ID="PageTitleInTitleArea" runat="server" contentplaceholderid="PlaceHolderPageTitleInTitleArea" > Site Template Information </asp:Content>



Save the page to your layouts folder (usually c:\program files\common files\microsoft shared\web server extensions\12\template\layouts\). Once the page has been saved, you can access it from any of your SharePoint sites via http://yoursharepointsiteaddress/_layouts/pagename.aspx

Source : http://blog.rafelo.com/


No comments:

ShareThis

snow flakes

blogger widgets Blogspot Tutorial

LinkWithin

Related Posts Plugin for WordPress, Blogger...