I'm trying to customize the page that is used to show the content of folders in a certain (dynamically created) list. This page appeared to be AllItems.aspx. To customize the page I decided to replace the AllItems.aspx with a custom one. I can't use SharePoint-Designer, only Visual Studio.

Whenever a list of this type is created I delete the AllItems.aspx from "ListName/Forms/AllItems.aspx" and use a feature with module to insert the custom page into that folder. Like that:

file = currentWeb.GetFile("OffeneVorgaenge/Forms/AllItems.aspx");
currentWeb.Features.Add(new Guid(Constants.FeatureIdVorgaengeAllItemsPage));
ActivateFeature(Constants.FeatureIdVorgaengeAllItemsPage, currentWeb);

However, after replacing the AllItems.aspx the page is no longer used to display the folder content, even though the replacement seemed to work fine (I checked if the file in the Forms-Folder is actually my customized AllItems.aspx and it was).

How can I fix this? Is there any smarter way to customize this page?

  • If the page is no longer being used, then what is? Perhaps you need to set the default view for your list? Does this scenario work if you do it manually? – BlueBird Jun 17 '13 at 14:57
  • Another page is being used. If I change that as well It's not being used as well. I figured the problem was that SharePoint detected that I deleted the form for the default view (AllItems.aspx) and enabled another view.. but don't quote me on that. – Luke Jun 18 '13 at 19:09

It depends what you are trying to achieve...

If you want to completely customise the list view page, or add content to it, you could modify the collection of web parts on that page with C# code. This would involve:

  • Creating a feature receiver within your solution that modifies the list view page web part collection (using SPWebPartManager or SPLimitedWebPartManager)
  • Either create a custom web part and add an instance of this web part to the list view page or add one of the web parts that are included with SharePoint (such as a Content Editor Web Part which can be used to render HTML content).

If you're using SharePoint 2013, you may want to look at Client Side Rendering via the JSLink property of the list view web part - this allows you to customise how the list view is rendered.


You can create a custom List Definion with a custom form or a list intance with a custom schema. A good tutorial with excellent examples you can/ must watch Core SharePoint List Development by Wouter van vught. This is one of the best overviews I have seen about list development.

  • It didn't help me directly since I had to work with the custom content types provided and couldn't create list definitions but it was definitely worth a watch, thanks for sharing! – Luke Jun 18 '13 at 19:07

Can you try setting the default page as part of your feature?

SPFolder rootFolder = currentWeb.RootFolder;
rootFolder.WelcomePage = "OffeneVorgaenge/Forms/AllItems.aspx";

If it is a publishing web then you should use currentweb.DefaultPage instead.

I am still a little unsure of what is going on but I Hope this helps...





allitems.aspx is a View. Each list has only one default view. When you deleted allitems.aspx, the next view became the default view. So, you may need to set your view back as the default view.

Url                        DefaultView
---                        -----------
Lists/Tasks/AllItems.aspx         True
Lists/Tasks/late.aspx            False
Lists/Tasks/Upcoming.aspx        False
Lists/Tasks/completed.aspx       False
Lists/Tasks/MyItems.aspx         False
Lists/Tasks/gantt.aspx           False
Lists/Tasks/calendar.aspx        False

This is PowerShell, but shows the objects you need to update:

$view = $list.Views["All Tasks"]
$view.DefaultView = $true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.