Tuesday, May 10, 2011

How to create an application page using Visual Studio 2010 for SharePoint 2010?





An application page is an ASP.NET Web page that is designed for use in a SharePoint Web site. We can attach the master page to an application page so that it will the page will have same appearance and behaviour like other pages. Application pages are shared across all sites on the server, whereas a site page is specific to one site.

Also check out:

- Content Editor Web Part in SharePoint 2010

- AllowUnsafeUpdates in SharePoint 2010

- Approve master page using PowerShell in SharePoint 2010

An application page is the best type of page to create if you want the page to contain custom code.

We can create an application page using visual studio 2010 for our SharePoint site. Please follow the below steps.

Step-1:
First create a Sharepoint 2010 empty project by going to File -> New Project -> then choose Empty Sharepoint Project template, then give a Name and location then click on OK.

Step-2:
Then in SharePoint customization Wizard Choose Local site URL and choose deploy as farm solution.

Step-3:
In this next step: Select the project name in the solution explorer and click on Add new Item then click on Application Page template and give a page name and click on OK. See the figure.


Step-4:
After that you can change the master page by selecting DynamicMasterPageFile="~masterurl/default.master"
and also you can write anything inside the ContentPlaceHolderID.


Step-5:
If you will look at the solution explorer there will be Layouts mapped folders like shown below.


Now you can debug by clicking on F5. Then you can visit the below URL
http://bsahoo3:8787/sites/Training/_Layouts/ApplicationPageTest/MyTestApplicationPage.aspx
Here ApplicationPageTest is the project name. You can check a very good SharePoint 2010 deployment article.



1 comment:

  1. What about the code behind? where to add the code behind and how to reference the aspx to use that code behind file. after deployment aspx should recognize the codebehind???

    ReplyDelete