Hi all,
In one of blog posts , I have walked through a simple technique though which we can create an applcation page which will be hosted on SharePoint 2007. We have to note few important points here:
1) Normal ASPX pages are quite different from SharePoint ASPX pages.
2) Customized application pages cannot be customized.
3) Application pages are based in the virtual _layouts directory and they are complied.
There is a much simpler way to create ASPX pages to be hosted onto SharePoint pages.
Step1: Create a new WSPBuilderProject. File >> New >> Project >> Choose WSPBuilder template.Project Name: CustomAppPage.
Step2: Right click on the CustomAppPage project >> Add >> New Item >> choose Feature with Receiver as follows:
A new folder will be created named "FeatureCode" and will contain 4 methods with some exceptions. Remove the exceptions.
Step3: Apparently, ASP.NET Project Types CAN NOT be embedded into WSPBuilder project. But there one way to enable those project types using following steps and you can follow my earlier post here.
Once we add the ASP.NET Project types we reload the project.
Step4: In our project we create a new folder named "LAYOUTS" under TEMPLATE folder. Right click on the "LAYOUTS" folder >> Add >> New Item and choose a the web form named "AppPage.aspx"
The folder structure will look this:
Step5: Now, we have add few elements:
i) Refer to SharePoint masterpage and supply the code file (Inherit)
ii) Supply the basic 3 content placeholders
iii) in the code file, we need to inherit the "LayoutsPageBase"
iv) Add reference to the Microsoft.SharePoint.dll
Here are the basic AppPage.aspx and the corresponding file
AppPage.aspx
---------------------------------------------------------------------------------
<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" AutoEventWireup="true" Inherits="CustomAppPage.AppPage, CustomAppPage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fe057018f74cd3a4" %>
<%--Control Place Holder--%>
<asp:Content ID="PageTitle" runat="server" contentplaceholderid="PlaceHolderPageTitle" >
Customer Page Title
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" runat="server"
contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
Customer Title Area
</asp:Content>
<asp:Content ID="Main" runat="server" ContentPlaceHolderID="PlaceHolderMain">
Custom Main
</asp:Content>
<%--Control Place Holder--%>
<asp:Content ID="PageTitle" runat="server" contentplaceholderid="PlaceHolderPageTitle" >
Customer Page Title
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" runat="server"
contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
Customer Title Area
</asp:Content>
<asp:Content ID="Main" runat="server" ContentPlaceHolderID="PlaceHolderMain">
Custom Main
</asp:Content>
---------------------------------------------------------------------------------
AppPage.aspx.cs
---------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace CustomAppPage
{
public partial class AppPage : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace CustomAppPage
{
public partial class AppPage : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
---------------------------------------------------------------------------------
NOTE: In the inherits, we have to provide the 5 part assembly name including the PublicKeyToken.
Step6: Deploy the solution and test it. We will get this kind of screen:
Cheers,
--aaroh
Download the source here
No comments:
Post a Comment