Skip to main content

Cloud

Customizing List Forms

MSDN has a very good article to customize list forms in 2003. This post explains how to do the same in 2007. I won’t be going through the steps for creating a custom list definition; there are many good articles for that.

In 2007 SharePoint, List pages for all the lists are rendered using 2 layout pages in 12TemplatePages folder: form.aspx and viewpage.aspx. Similar to how a publishing page is rendered, SharePoint uses the default.master and "form.aspx" to render NewForm/DispForm/EditForm pages while AllItems.aspx page is rendered using "viewPage.aspx" layout. So, any changes to those two layout pages gets reflected in all the lists/document libraries in all SharePoint web applications on that server. When I said ALL lists..I lied :); Picture Library is an exception here, It has its own set of pages.

To have custom list pages for a custom list definition, just like the Picture Library, it needs to have its own set of pages. The only trick here is to make your list definition use those pages. We’ll follow Picture Library’s Schema.xml to associate custom pages to the custom list definition:

  • Copy AllItems.aspx, DispForm.aspx and EditForm.aspx from FeaturesPictureLibraryPicLib folder in to your custom list definition feature folder that contains the list schema.xml. Picture Library has Upload.aspx but no NewForm.aspx.
  • Create NewForm.aspx by making a copy of AllItems.aspx (you can use DispForm or EditForm.aspx also) and rename it to "NewForm.aspx".
  • Make your customizations to these pages. In my case, I created a list definition which had a custom web part in all the pages.
  • Open Schema.xml and update the <Forms> section to delete the "SetupPath" attribute from the Form nodes as shown below.

<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="Main" />
</Forms>

  • By deleting the "SetupPath" attribute, we are telling SharePoint to look for ".aspx" pages named after the "Type" attribute in the same folder as Schema.xml.
  • "AllItems.aspx" is associated with the default view of the list. Similar to the above change, delete "SetupPath" attribute from the default view node in the schema.
  • Save your changes and install the feature.

That is all you need to do.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Raja Ayyapusetty

Raja is a software consultant with over 9 years of experience in designing, developing and testing complex solutions using Microsoft technologies. Throughout his career he has worked primarily on SharePoint and .NET technologies. Raja has worked with SharePoint since the 2003 version and has deep understanding of its features and capabilities. Raja is also a certified Sitecore developer.

More from this Author

Follow Us