SharePoint · SharePoint 2010

SharePoint 2010 – Updating custom forms on an existing list

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=>

<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 />




Please leave a comment or feedback

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