Create a Custom User Control for SharePoint 2010

How to create a custom User Control for use in SharePoint Master Pages, Application Pages and Web Parts.

Building the custom the control using Visual Studio 2010

  • Open Visual Studio 2010 and start a new empty SharePoint Project
  • Add a User Control to the project from the list of templates for SharePoint 2010
  • Add some content or ASP controls to the user control (.ascx file)
  • Add code to the .ascx.cs file to populate the User Control with dynamic or static data

Applying The User Control to a page:

Master Page, Application  Page or .aspx page:

  • Register the control at the top of the page, giving it a tag name and tag prefix for use in the page content
  • Add the user control to the page content using <tagprefix:tagname … >, where tagprefix is the prefix specified when registering the control on the page, and tagname is the name also specified when registering the control.

The summary of steps above were taken from the complete tutorial linked below.  For full details including step by step instructions to build an example User Control that displays the Site Title, List Title and Item / Page details and how to add the User Control to an Application page, please see the following:

Related posts:

  1. Add custom Site Title link to homepage of site to a SharePoint Master Page
  2. Custom Publishing Page Layout using SharePoint Designer
  3. Many SharePoint Designer 2010 Tutorials
  4. Many SharePoint Branding Resources: Change Site Logo & more using CSS and Masterpages – SharePoint 2010
  5. SharePoint & InfoPath Resources

Tags: , ,

Comments are closed.