Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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");
file.Delete();
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?

share|improve this question
    
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

3 Answers 3

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.

share|improve this answer

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.

share|improve this answer
    
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";
rootFolder.Update();

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

References:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.publishingweb.defaultpage.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.welcomepage.aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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