Sunday, February 27, 2011

Creating and deploying Application page to your SharePoint application

What are application page?
Actually there are two types of page available in SharePoint.
1. Site Pages: Those pages which supports user customization by some designing tools e.g. SharePoint designer.
2.Application Pages: The pages which does not support user customization. You can find application pages in \Layout directory. You can create your own application page and you can deploy it to your sharepoint application.

Open visual studio and create a simple web application.

Paste the below code in your .aspx page.

<%@ 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" %>



"Main" runat="server"
contentplaceholderid="PlaceHolderMain" >
Site Title: "lblSiteTitle" runat="server" />


Site ID: "lblSiteID" runat="server" />


"PageTitle" runat="server"
contentplaceholderid="PlaceHolderPageTitle" >
Hello World


"PageTitleInTitleArea" runat="server"
contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
The Quintessential 'Hello World' of Application Page


Deployment

Note that although you can deploy your application pages directly inside the \LAYOUTS directory, doing so can create file name conflicts between your application pages and those application pages that are created by Microsoft and other companies. It is a best practice to deploy your application pages inside a company-specific or project-specific directory that is nested with the \LAYOUTS directory. For example, you can deploy application pages within a company-specific directory located at the path \LAYOUTS\your-project-folder-name

Now you can see your application page in your SharePoint application.

Lots more on Application page....coming soon......




Monday, February 7, 2011

Creating a Simple web part

Here are the steps to create a simple web part in Visual Studio and deploy it into your sharepoint application:

Open Visual Studio and select a web part from project template.

Add Refrence:

Microsoft.SharePoint;

Now write below code:

protected override void CreateChildControls()
{
Lable lbl = new Lable();
lbl.Text="Hello To SharePoint Coding Blogs";
this.controls.add(lbl);
}

Build the Application.
Go to your project folder
And under Bin folder you will find .dll file.
Drag this .dll file into C:\windows\assembly

Now go to C:\inetpud\wss\Virtual Directory\your project name

Open web.config file

And under safe control tag put this code:

namespace= namespace name, Assembly=your assembly name, culture=nuetral
version=12.0.0.0, PublicKeyToken=7888etr77


Go to your Sharepoint application.
Site Actions->Siet settings

Under gallery section click on web part.
Click new.
Then select your class file and populate it.
Link
After that go to your site page and click edit page under site actions.

Click on add a webpart.
Select your webpart from web part gallery.

That's done.


For more please visit : www.sharepointcafe.net