共用方式為


List Item Form Pages

Applies to: SharePoint Foundation 2010

The list item form pages (DisplayForm.aspx, EditForm.aspx, and NewForm.aspx) for most Microsoft SharePoint Foundation lists are based on the same Form.aspx file that is located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\Pages. This file implements the SharePoint Foundationdefault.master file that is located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\GLOBAL.

By default, list form pages run in no-compile mode for better scalability. SharePoint Foundation does not allow code on form pages unless allowing code on pages is enabled through the user interface.

List Item Forms and Master Page

Default list form pages are designed according to the default master page, with each area for the control represented by a placeholder on the page. A list form page contains placeholders for the toolbar, header, body, and footer. Each specific form page determines what controls to use in those placeholders, which requires the overall master page design with its nested (derived) master pages.

The master page defines the borders and navigational areas displayed on list item forms. For information about master pages in SharePoint Foundation, see Master Pages.

The Form.aspx file contains a Microsoft.SharePoint.WebPartPages.WebPartZone control that inserts a ListFormWebPart object in the body of the page. To display the contents of the page, this Web Part instantiates a ListForm control whose template is defined in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\CONTROLTEMPLATES\DefaultTemplates.ascx. The ListForm control contains HTML markup and control templates to lay out the toolbar, fields, and other parts of the form. You can specify a custom ListForm control through template properties of the ListFormWebPart class.

Important

Editing the files that SharePoint Foundation installs on front-end Web servers is not supported. Changes you make to files that were originally installed with the product can be overwritten when you install updates or service packs for SharePoint Foundation, or when you upgrade an installation to the next product version.

Display Form Rendering

SharePoint Foundation display forms have slightly different rendering than the edit and new forms, because although display forms have the same layout as the edit and new forms and share most controls, display form fields are defined in unmanaged code and have the same field rendering that is used in the list views. In display mode, SharePoint field controls use Collaborative Application Markup Language Core Schemas definitions to render the fields.

Important

Although you can add Web Parts to the Display, Edit, and New forms for list items (DispForm.aspx, EditForm.aspx, and NewForm.aspx), doing so is not recommended or supported in SharePoint Foundation. Adding Web Parts to list view pages (AllItems.aspx) is supported.

Specifying Custom Pages for Creating or Modifying Lists

You can specify a custom page for creating lists or for editing list properties by specifying the NewPage and EditPage attributes on the ListTemplate element of a list definition Feature.

The following example specifies custom pages for lists created through the list definition.

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <ListTemplate
    Name="MyTemplate"
    Type="2100"
    BaseType="1"
    OnQuickLaunch="TRUE"
    SecurityBits="11"
    DisplayName="My Custom List Type"
    NewPage="MyCreateList.aspx"
    EditPage="MyEditList.aspx"
    Description="My description..."
    Image="/_layouts/images/itsl.gif"
    DocumentTemplate="100">
  </ListTemplate>
</Elements>