SharePoint 2010

Custom List Definition: Adding Custom List Pages (AllItems.aspx, DispForm.aspx, EditForm.Aspx & NewForm.aspx)


There is always a need for adding Custom List Pages (AllItems.aspx, DispForm.aspx, EditForm.Aspx & NewForm.aspx) to your list definition. By adding custom list pages to your custom List Definition

  •   You get more control on Customization of View, Edit and New form for your custom list definition
  •   Add JavaScript, Web parts to those pages

This is very easy to achieve. All you need to do is make your Custom List Definition refer those pages instead of default Out of Box pages. Below are steps

1. Making a Copy of existing files

Here instead of creating our own pages, you can just copy the existing pages.

  1. You can deploy your Custom List Definition to your development server.
  2. Create a List instance from your Custom List Definition
  3. Open Site in SharePoint Designer 2010
  4. Copy content of all list pages Allitems.aspx, DispForm.aspx, EditForm.aspx & NewForm.aspx to different files and named them MyAllItems.aspx, MyDispForm.aspx, MyEditForm.aspx & MyNewForm.aspx
  5. Now Open the MyAllItems.aspx and remove the code <WebPartPages:XsltListViewWebPart … >  & 

    </WebPartPages:XsltListViewWebPart>. What you need to do just remove the XSLTLISTVIEWWEBPART from the MyAllItems.Aspx

  6. Save the modified file.

Follow above steps 1 to 4 or all other files. Please skip steps 5 & 6 for other files.

2. Deploying above files to Feature Folder

Here we will have to add all modified files to our solution in VS, so that those modified will be deployed to server when List Definitions features is deployed

  1. In Visual Studio add all above modified files to List Definition folder where you Schema.xml exists
  2. Open SharePointProjectItem.spdata file from your List Definition folder in VS
  3. Add below code

<ProjectItemFile Source=”MyAllItems.aspx” Target=”MyListDefinition\” Type=”ElementFile” /> in files tag.

similarly follow steps 2.1 to 2.3  for all other files

3. Changing the association of list pages

Now the final step is to associate modified list pages with List Definition.

  1. Open Schema.xml file of List Definition.
  2. Under <Forms>, remove attribute SetupPath=”pages\form.aspx” from all forms types like DisplayForm, EditForm & NewForm.

Note: 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

3. “AllItems.aspx” is associated with the default view of the list. so, delete “SetupPath” attribute from the default view node in the schema.

    This is all we have to do for having custom list pages for list definitions.

    Enjoy!!

     

Advertisements

11 thoughts on “Custom List Definition: Adding Custom List Pages (AllItems.aspx, DispForm.aspx, EditForm.Aspx & NewForm.aspx)

  1. THIS METOD DON`T WORK!!!!!!
    IF I COPY FILE NEWFORM.ASPX WITH LISTFORMWEBPART – LISTFORMWEBPART CONTENT PARAMETER LISTNAME AND LISTID – THIS IS CONSTANT.
    CREATE NEW LIST WITH THIS LISTDEFINITION HAS OTHER LISTNAME AND LISTID!!!!!!

  2. Hi Anton,
    You have to remove your ListFormWebPart.
    Pathi came up with a step of deleting the XSLTLISTVIEWWEBPART. Looks like you have ListFormWebPart instead of XSLTLISTVIEWWEBPART .

  3. Let me tell that you’re placing great deal of time and to your blog and detailed articles! I love to deeply gets interested every item of info you post here (you will discover more or less not some quality blogs left .

  4. I’m trying to created a MyAllItems.aspx as well but it’s not working. One thing to note is that I’m doing this in a sandboxed solution.

    Once my list is created I can go and create view and I will see my new view as a template.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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