I was working on this SharePoint solution where we have a whole bunch of content types, site columns and feature receivers that are adding content types to document libraries on the fly. We were doing this because the client didn’t want to use list instances in the site definitions.
So I had this very bizzare issue when in some document libraries when I was uploading a document the edit form was not shown at all. So I choose “Upload”, browse to a file, hit “OK” and instead of getting the edit form to fill in the metadata I was getting redirected to the default view of the list. The file was being uploaded successfully but the user couldn’t change the metadata during the upload. And this was happening only on some document libraries but not on others.
A quick look to the SchemaXML of some of the libraries with SharePoint Explorer revealed that the document libraries that were having the problem were missing the “Folder” content type. And unfortunately you cannot see this content type from the UI so from the UI all of the libraries were looking the same. However I could browse for the “Folder” content type and add it to my library. After doing this with the problem was resolved and the edit form was being shown once again …
Determined to find out the root of this strange behaviour I checked the code of the Upload.aspx page in the 12 hive and it releaved the code behind class used by the page:
<%@ Assembly Name=”Microsoft.SharePoint.ApplicationPages, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c”%>
<%@ Page Language=”C#” Inherits=”Microsoft.SharePoint.ApplicationPages.UploadPage” MasterPageFile=”~/_layouts/application.master” %>
I then started Reflector and checked what happens when the user hits “Submit”. An excerpt is shown below
protected void OnSubmit(object o, EventArgs e)
if ((!this.IsSimpleList || (spfile.CheckOutStatus != SPFile.SPCheckOutStatus.None)) && (spfile.Item != null))
SPUtility.Redirect(this.GetEditFormUrl(spfile), SPRedirectFlags.Default, this.Context);
As the code shows the user is only redirected to the edit form if the file is checked out or if the document library is not a “Simple List”. Checking the code of the IsSimpleList property showed that “Simple Lists” are lists that have only one content type and don’t have their “Title” field marked as “ShowInEditForm” = “FALSE”
In my case when the “Folder” content type was not present the document library was having only one content type and was qualifying as a “Simple List” and as a result the edit form was not shown when uploading a document!
So what’s the moral of the story … well I guess don’t delete the “Folder” content type from your document libraries