Creating a Visual Studio solution for custom delegate controls

Delegate controls provide a mechanism for adding ASP.NET user controls. As such, to create, compile, and package custom controls, we will use a Visual Studio solution. In this recipe, we will create the Visual Studio SharePoint project that we will use for this chapter. For simplicity, we will add each subsequent recipe to this single project.

Note

Since the recipes in this chapter include items that will make changes to the web.config file of the SharePoint web application in IIS, we will be creating a farm solution.

Getting ready

In order to create a custom SharePoint solution with Visual Studio, we will need to have Visual Studio 2012 with the Office Developer Tools or Visual Studio 2013 applications installed on a computer running SharePoint Server 2013. In addition, we will need local computer administrator and SharePoint farm administrator access.

Tip

If using PowerShell to deploy the custom SharePoint solution, SharePoint shell access to the SharePoint configuration database in SQL will also be required. Refer to http://technet.microsoft.com/en-us/library/ff607596.aspx for more information on adding a SharePoint shell administrator.

How to do it...

Follow these steps to create a Visual Studio solution for custom-delegate controls:

  1. Open Visual Studio running as administrator.
  2. From the File menu, select New Project.
  3. Select the SharePoint 2013 – Empty Project template by navigating to Templates | Visual C# | Office/SharePoint | SharePoint Solutions as shown in the following screenshot:
    How to do it...
  4. Provide values in the Name and Location textboxes for the project and click on OK.
  5. Provide the URL to the local SharePoint site you will be testing with:
    How to do it...
  6. Select Deploy as a farm solution and click on Finish.
  7. Add project references to System.Configuration and Microsoft.SharePoint.Publishing. The Microsoft.SharePoint.Publishing assembly can be found at C:Program FilesCommon FilesWeb Server Extensions15ISAPI.
    How to do it...
  8. Right-click on the project name in the Solution Explorer pane.
  9. Navigate to Add | New Folder as shown in the following screenshot:
    How to do it...
  10. Create a folder named Controls. We will use the Controls folder later in the chapter to store all of our code-only user controls.
  11. Right-click on the project name.
  12. Navigate to Add | SharePoint Mapped Folder… as shown in the following screenshot:
    How to do it...
  13. Select the CONTROLTEMPLATES folder under the TEMPLATE folder. We will use the CONTROLTEMPLATES mapped folder to store all of our ASCX user controls later in the chapter.
    How to do it...
  14. Click on OK.
  15. Add a folder in the CONTROLTEMPLATES mapped folder with the same name as the project. When working with mapped folders, it is important to place items in a subfolder that is unique. This will alleviate any collisions with files of the same names included with SharePoint or provided by other custom solutions.
  16. Click on the SharePoint "Layouts" Mapped Folder option to add the Layouts mapped folder, which we will use later in the chapter to store our application page, stylesheets, and JavaScript:
    How to do it...
  17. Click on Save All from the toolbar or File menu.

How it works...

Our Controls folder will act like a folder does in a standard .NET class library to provide organization and namespaces. The CONTROLTEMPLATES mapped folder will instruct SharePoint to deploy the ASCX files for our user controls to the appropriate place on the filesystem (C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15TEMPLATECONTROLTEMPLATES). The Layouts mapped folder will instruct SharePoint to deploy our application page, stylesheets, and JavaScript to the appropriate place on the filesystem to allow them to be accessed from the client web browsers (C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15TEMPLATELAYOUTS).

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.156.251