Followed Steps To Register a Control in SharePoint 2007

Example : Control to deal with Sharepoint List

1 – Create A List in Your Portal  as the following Steps

to customize the List Fields click on Settings >> List Settings,

after that you can add,delete,edit  List Columns

2 – Create new Project >> Add New Web User Control to Add New Employee

as the following snapshot :

* Add reference to Microsoft.Sharepoint.dll to your solution

in the Add Button Click write the following Code:

SPWeb mySite = SPContext.Current.Web;

SPListItemCollection listItems = mySite.Lists[“Employees”].Items;

SPListItem item = listItems.Add();

item[“Title”] = TextBox1.Text;

item[“FullName”] = TextBox2.Text;

item[“Email”] = TextBox3.Text;

item[“Mobile”] = TextBox4.Text;


Build Your Project

3 – Make signing for your Assembly

Project Properties >> Signing Tab >> Mark [Sign the assembly] >> choose from the next List  [New]

>> Name it >> Build the Project Again

4 – Open your virtual sharepoint server

4.1 Copy your project’s Dll and paste it in the folloiwng path on the server                C:\WINDOWS\assembly

4.2 Copy your control html only to the following path

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES

or you can make a folder for your project so the path will be as the folloiwng

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\MyProject\Controls\

4.3 open your portal web.config on the server add new assembly key with your project dll to tag <assembly> as the following :

<add assembly=“MyProject, Version=, Culture=neutral, PublicKeyToken=9a94956654413ddf” />
you can find assembly name and it’s publickeytoken from the assembly folder by searching for your dll
and right click to get it’s properties
Save the file

5 – Open Sharepoint designer 2007

5.1 open your web portal

5.2 find your list in folder Lists on the left section        don’t forget “Employees” List

5.3 Add new aspx page

to make the page attached to a master page

Format Menu >> Master Page >> Attach Master page

in the page top section

add tag prefix to your control like this

<%@ Register src=”~/_CONTROLTEMPLATES/MyProject/Controls/Add.ascx” tagname=”Addemp”  tagprefix=”UC” %>

in the page body use the control as you see

<UC:Addemp runat=server></UC:Addemp>

6 – Final Step open cmd and reset your iis by the following command


7 - Test your page and try to add new employee and go to AllItems.aspx page and see the result 


One thought on “Followed Steps To Register a Control in SharePoint 2007

  1. That is a good tip especially to those new to the blogosphere. Simple but very accurate information… Thank you for sharing this one. A must read article!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s