What do you do when you have a list with custom forms (editform.aspx, dispform.aspx and newform.aspx) and you want to add some extra fields on that form.

Ok, so you get SharePoint Designer out and make the modifications to the forms. But how do we deploy this?

First I created a feature with an FeatureActivated Method

public override void FeatureActivated(SPFeatureReceiverProperties properties)

   SPWeb web = (SPWeb)properties.Feature.Parent;

   SPList list = web.Lists[“Project Status Report”];

   //Get the Content Type used for this list

   SPContentType ctCustom = list.ContentTypes[“MyContentType”];

   if (ctCustom == null)


       throw new NullReferenceException(“Content Type MyContentType not found”);




         // Update Edit, Display and New Forms

ctCustom.EditFormUrl = “Lists/MyList/csEditForm.aspx”;

ctCustom.NewFormUrl =“Lists/MyList/csNewForm.aspx”;

ctCustom.DisplayFormUrl =“Lists/MyList/csDispForm.aspx”;

ctCustom.Update(false); //do not update children


Now all we have to do is add the forms to the library (adding the forms to other locations will give you errors related to the master page file).

In the same feature add the forms to a Forms Folder and update the elements.xml of the feature with the following content. Make sure that you give the forms a name different from the standard editform.aspx, newform.aspx and dispform.aspx. As this will not replace existing forms.

<?xmlversion=1.0encoding=utf-8 ?>

<Elements xmlns=http://schemas.microsoft.com/sharepoint/>

<Module Name=ListForms Url=Lists/MyListPath=Forms>

   <File Url=csEditForm.aspxName=csEditForm.aspxType=GhostableIgnoreIfAlreadyExists=TRUE />

   <File Url=csDispForm.aspxName=csDispForm.aspxType=GhostableIgnoreIfAlreadyExists=TRUE />

   <File Url=csNewForm.aspxName=csNewForm.aspxType=GhostableIgnoreIfAlreadyExists=TRUE />



Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: