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 haven't been able to find any information regarding this, so I hope you guys can help me out on this.

Since all lists in SharePoint all have an EditForm.aspx and a DispForm.aspx I am wondering if these pages are generated out of a template?

If they are, does anyone know if they are editable so it's possible to customize them so future lists will inherit the changes -- and would you recommend doing it?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

If you want to customize a list new\edit\display form there is a couple of ways you can do it. I mean programming ways (not InfoPath). All this methods related to creating custom rendering templates. Every list form has its own rendering template, for list its a "ListForm", for document library "DocumentLibraryForm". All this templates (and otheres) listed in DefaultTemplates.ascx file. Additional reading about how to create custom rendering template you can find here and here.

  1. Content Type. If content types enabled for list, when you are createing new item, you can select what content to use and you can override default rendering template for this particular content type.
How to do it:
If you are using custom content type, you can specify rendering template in schema:

    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
        <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
          <Display>YourCustomTemplateName</Display>
          <Edit>YourCustomTemplateName</Edit>
          <New>YourCustomTemplateName</New>
        </FormTemplates>
      </XmlDocument>
    </XmlDocuments>
    .......
</ContentType>

If you want to do it programmatically:

var list = web.Lists["MyList"];
var cp = list.ContentTypes["MyCP"];
cp.EditFormTemplateName = "YourCustomTemplateName";
cp.Update();  

  2. Custom list schema. In list schema there is a section named Forms, for every form you can specify custom rendering template name:

<Forms>
   <Form Type="DisplayForm" Url="DispForm.aspx" Template="CustomSurveyListForm" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="EditForm" Url="EditForm.aspx" Template="SurveyForm" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="NewForm" Url="NewForm.aspx" Template="MyNewSurveyForm" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>  

  3. Existing (may be out-of-the box) list. I don't know the right way how to do it (except InfoPath of course). Object model for list has property named Forms, and you can get instance of specific form using code list.Forms[PAGETYPE.PAGE_EDITFORM] but SPForm.TemplateName has no setter... The only way that I can suggest - copy definition for oob list, customize forms section and then create list using xml ListInstance element and CustomSchema attribute.
Hope this helps.

share|improve this answer
add comment

The EditForm.aspx and DispForm.aspx are the form pages available in all lists. These pages contains the ListForm webpart, that will render the webpart to newform or editform based on parameters we have provided in the webpart. (The controls are available in ControlTemplates folder under 14 hive folder)

Or we can modify the webpart using Infopath form or SharePoint Designer. After that we can save the list as a template and create a list using the template will provide you the modify the forms.

Or we have to create a List Template using List Definition file with the Forms information, will have a list with your user - defined forms.

share|improve this answer
    
But what if I want to modify the SharePoint standard lists' forms -- like Announcement list, Custom list, Calendar, without making new List Templates or List Definitions? –  Daniel Ziga Dec 29 '11 at 9:47
    
Can we change which editform a list or library uses by default? i.e. can we change the defaulteditformurl through SharePoint designer? –  David Dec 11 '12 at 20:56
add comment

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.