Powered By Blogger

Monday, November 28, 2011

How to create custom Application Page (aspx page) for SharePoint 2010 using VS 2010


1. In Visual Studio 2010 IDE create new “Empty SharePoint Project” by going into File > New > Projects > SharePoint > 2010. Make sure to select .Net Framework 3.5 in version selector drop down list.

2.







2. Select farm solution as trust level for debugging this application.











3.Right click on project in Solution Explorer and add new item and add “Application Page”. This will add an aspx page in a Mapped “Layouts” (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS) folder. This is because when you will deploy your application page to SharePoint it will host this application physically into Layouts directory.










4. Write some code in .cs file of aspx page as I have written a two number add program

Open aspx page of application page and refer page directive at the top “<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyApplicationPage.aspx.cs" Inherits="SharePoint2010ApplicationPage.Layouts.SharePoint2010ApplicationPage.MyApplicationPage" DynamicMasterPageFile="~masterurl/default.master" %>It do reference ~masterurl/default.master. This application page can be accessed by using any site collection url in SharePoint farm. Using url like ( http://yoursite/_layouts/ApplicationPage.aspx).
















5. Now all development done, we should deploy this application page to SharePoint Server. To deploy on development server you just have to right click on project in solution explorer and select deploy, It will deploy the application on development machine Layout folder.

To deploy the same on production environment we need to create a solution package (wsp package ) , Creating wsp package in Visual Studio 2010 get very easy as you package by right clicking on project file and selecting package it will create a wsp file in bin folder.

No comments:

Post a Comment