A useful article on Application pages
http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
Spiga
Monday, July 21, 2008 at 6:31 PM Posted by Peter
A useful article on Application pages
http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
Labels: application pages, code behind, sharepoint 0 comments
Wednesday, July 2, 2008 at 11:15 PM Posted by Peter
The Awesome power of Application Pages
A useful link http://msdn.microsoft.com/en-us/library/bb418732.aspx
In VS.Net 2005 on your MOSS Server Development Environment create an empty Sharepoint Project. (I called mine MOSS.Web.Application)
Add a reference to Microsoft.SharePoint (Windows® SharePoint® Services) v2.0.50727
In my environment its at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
(If you can't work out which one to choose add a webpart to the solution then delete the Webpart bits that were just added)
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Assembly Name="MOSS.Web.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken={PUBLIC KEY TOKEN}"%>
<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"
Inherits="MOSS.Web.Application.Basic.Default" %>
<asp:Content ID="Main" runat="server" contentplaceholderid="PlaceHolderMain" >
Site Title: <asp:Label ID="lblSiteTitle" runat="server" />
<br/>
Site ID: <asp:Label ID="lblSiteID" runat="server" />
</asp:Content>
<asp:Content ID="PageTitle" runat="server"
contentplaceholderid="PlaceHolderPageTitle" >
Hello World
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" runat="server"
contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
The Quintessential 'Hello World' of Application Page
</asp:Content>
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace MOSS.Web.Application.Basic
{
[CLSCompliant(false)]
public class Default : LayoutsPageBase
{
// add control fields to match controls tags on .aspx page
protected Label lblSiteTitle;
protected Label lblSiteID;
protected override void OnLoad(EventArgs e)
{
// get current site and web
SPSite siteCollection = this.Site;
SPWeb site = this.Web;
// program against controls on .aspx page
lblSiteTitle.Text = site.Title;
lblSiteID.Text = site.ID.ToString().ToUpper();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Solution SolutionId="ce340c94-3b75-4abd-9a2d-537b8db6ada5" xmlns="http://schemas.microsoft.com/sharepoint/">
<Assemblies>
<Assembly Location="MOSS.Web.Application.dll" DeploymentTarget="GlobalAssemblyCache" />
</Assemblies>
<TemplateFiles>
<TemplateFile Location="LAYOUTS\Basic\default.aspx" />
<TemplateFile Location="LAYOUTS\Basic\Default.aspx.cs" />
<TemplateFile Location="LAYOUTS\Basic\Web.config" />
</TemplateFiles>
</Solution>
Labels: application pages, sharepoint 0 comments