Wednesday, January 12, 2011

How to add a page in pages directory of Sharepoint site

Suppose you want to add a new page in the pages library of your sharepoint site programatically, how will you go about it.

Create the structure in your project -

12 - template - features - NewPageFeature -

In that create an aspx page, a feature.xml file and an elements.xml file

You will also need a cs file outside of the 12 folder, and will provide the path to the same in your aspx file.

Feature.xml ---------------------------------------------------------

Feature Id="94D273A9-B9AE-46f0-A56A-03289ACC87FF"
Description="Activate Chat Page"
ElementManifest Location="Elements.xml"/

Element.xml -----------------------------------------------------------

?xml version="1.0" encoding="utf-8"? Module Name="Pages" Url="$Resources:cmscore,List_Pages_UrlName;" Path="" RootWebOnly="False"
File Name="Chat.aspx" Url="Chat.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="False" /

.aspx file ---------------------------------------------------------

In your aspx file, include the path of you cs file like below -

Inherits="Eversheds.InstantMessaging.Chat, Eversheds.InstantMessaging,Version=,Culture=neutral, PublicKeyToken=b0c7276684f0a390"

Run wsp builder and your page will be created in the pages directory of your site

No comments:

Post a Comment