Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top