Problem
You’ve developed some custom new, edit and display application pages that are stored in the _layouts directory. Let’s assume the filenames are newform.aspx, dispform.aspx and editform.aspx. You now want to change the properties of your custom list so that any new, edit or display requests point to your custom pages.
If you open up your site within SharePoint Designer and expand the Lists folder, from there you can access the properties of that custom list by right clicking on it and selecting Properties. Once the List Properties pane is open, click on the Supporting Files tab.

You’ll see there that you can actually choose what display, edit and new forms you want your list to be using. So if you’ve developed something custom, you would click Browse…, point to your new location and select the file. Here is where it starts to fail, I am only able to browse within the site itself and cannot navigate to my _layouts directory to select the files I mentioned above.
Solution
I suspected this was a limitation of the SharePoint Designer UI and not actually a limitation of the Object Model. I did a bit of fiddling with my SPList object and was not able to find anything that let me change those properties. If you look at the screenshot above, there is a key piece of information that’ll make the light turn on (at least it did for me). The Supporting Files tab has a drop down selector for the Content type specific forms. If you think about that a moment, you’ll remember that ALL lists within SharePoint inherit from a default content type.
So armed with that knowledge, I created an SPContentType object and took a look at it’s properties and methods. Sure enough, there are 3 properties I can set to change these forms: EditFormUrl, NewFormUrl and DisplayFormUrl. Here is some sample code I used to change the forms for my custom list called ‘My List’ that inherits from the Item content type:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | SPWeb web = SPContext.Current.Web; web.AllowUnsafeUpdates = true; SPList list = web.Lists["My List"]; SPContentType ct = list.ContentTypes["Item"]; ct.EditFormUrl = "_layouts/editform.aspx"; ct.NewFormUrl = "_layouts/newform.aspx"; ct.DisplayFormUrl = "_layouts/dispform.aspx"; ct.Update(); list.Update(); |
So in the example code above, I had to determine what default content type my list inherited from. In this case it was the Item content type.
NOTE: If you need to change the content type directly, you can definitely do that, however, I did a bit of testing and found that any lists ALREADY inheriting from that content type did not pickup my changes to the form locations. Any NEW list that I created that was inheriting from that content type did pickup the changes. In order for me to change the form locations for the existing list I had to use the code above. For reference, here is how you would change the content type directly. The code has only a subtle difference.
1 2 3 4 5 6 7 8 9 10 11 | SPWeb web = SPContext.Current.Web; web.AllowUnsafeUpdates = true; SPContentType ct = web.ContentTypes["Name Of Your Content Type"]; ct.EditFormUrl = "_layouts/editform.aspx"; ct.NewFormUrl = "_layouts/newform.aspx"; ct.DisplayFormUrl = "_layouts/dispform.aspx"; ct.Update(); |
As always, any questions, let me know!





[...] How To Change the Default EditForm, NewForm and DispForm [...]
Hi,
Interesting post but i was wondering where those codes fit and what kind of project you need to build to deploy them. did you have to create a feature for that?
Hi Matt,
Actually, I don’t create any sort of project. I usually just put the files in the layouts directory in some sub folder and use a console app to redirect the edit, disp and new form urls. What part are you getting stuck on?
Actually, what I think Matt was asking, or at least what i want to ask, is “where do you put the software (what you call “sample code”) that you developed?”
hey Bruce and matt. I’ve had a lot of feedback about this post, so let me write up a follow up on the weekend, and i’ll post it Monday that will clarify this, as well as some code for download. Would that help?
Yes, indeed.
Sorry all, running a bit behind this week, will get the post update done this weekend. half way there.
so no one has had a problem with this not working? because it’s not working for me. is there maybe a more awful work around? with sharepoint the more disgusting a solution looks the more likely it’s the one that works and i’ve wasted enough time exploring sensible dead ends in this thing. so if someone has something involving human sacrifice in order to change a simple default form setting, fire away
can you be more specific about what’s not working? I’d like to try and help but without some more details, it’ll be a bit tough. maybe drop me a line via email and we can see if we can sort out your challenges. are you working with sharepoint designer or building out the aspx pages in visual studio?
bruce, just a quick comment on this (new post isn’t done yet), in terms of ‘where’ to put the sample code files. I setup a console application in Visual Studio and just added a reference to the Microsoft.SharePoint.dll file. And then in Main, I added the code sample above.
Does that help at all?
hi,
I need to change the error form I want to display the errror in custom way.
help me please.
Hi Zaid,
Where are you trying to display the error? On your custom form?
[...] http://blog.qumsieh.ca/2009/05/15/how-to-change-the-default-editform-newform-and-dispform/ Advertisement GA_googleAddAttr("AdOpt", "1"); GA_googleAddAttr("Origin", "other"); GA_googleAddAttr("theme_bg", "ffffff"); GA_googleAddAttr("theme_text", "000000"); GA_googleAddAttr("theme_link", "b54141"); GA_googleAddAttr("theme_border", "eeeeee"); GA_googleAddAttr("theme_url", "b54141"); GA_googleAddAttr("LangId", "19"); GA_googleAddAttr("Tag", "sharepoint-2010"); GA_googleAddAttr("Tag", "sharepoint-foundation-2010"); GA_googleFillSlot("wpcom_sharethrough"); Me gusta:Me gustaSé el primero en decir que te gusta esta post. Dejar un comentario [...]
[...] from an event handler to some sort of custom workflow logic. In our case, since the forms were custom ASP.NET forms submitting programmatically to the list, it was easy enough for me to track any changes to the date received column, and if I do find that [...]