SharePoint Internals – Hristo Pavlov’s Blog

30 April, 2008

EditForm.aspx not shown when uploading a document

Filed under: SharePoint — Tags: , , , , , — hristopavlov @ 7:56 am

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=12.0.0.0, 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.MultipleUploadMode)

    {

        …

 

        if ((!this.IsSimpleList || (spfile.CheckOutStatus != SPFile.SPCheckOutStatus.None)) && (spfile.Item != null))

        {

            SPUtility.Redirect(this.GetEditFormUrl(spfile), SPRedirectFlags.Default, this.Context);

            return;

        }

 

        …

 

    }

}

   

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

About these ads

2 Comments »

  1. Hi,

    I want to remove the calling of editform.aspx page for all document. It even calls when I upload new or re-upload the document.

    Comment by zishan — 16 December, 2009 @ 7:03 pm

  2. You need to override the existing OnSubmit event of Microsoft.SharePoint.ApplicationPages.UploadPage

    protected void OnSubmit(object o, EventArgs e)
    {
    SPUtility.Redirect(defaulviewURL);
    }

    Comment by shahejad — 28 October, 2010 @ 10:43 am


RSS feed for comments on this post. TrackBack URI

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

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: