ARTICLES

Home  > Articles  >  Edit SharePoint Display/New and Edit form look, feel, and functionality
Here is a scenario: you have a SharePoint list (calendar, announcements etc) and your users have requested special changes on out of the box display, new, or edit forms. Whether it`s few extra webparts added, or make another form that will serve a purpose of print friendly version

Here is how to approach it:

We`ll assume that you start with defining a list or document library token above in a new solution.
We`ll use custom list here as an example.
If you take a look at the definition of the custom list from the12 hive (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\CustomList) you will see that there is a schema.xml which defines all of the fields and views for this list and CustomList.xml defining type, image, and other list properties.

The easies is to copy the existing list and customize schema.xml and  template definition file to match your needs.

Now to the interesting part, where we will be modifying the masterpage of the default form.

In your schema.xml scroll to the very bottom where you will see the following section defined:

<Forms>
<Form Type=”DisplayForm” Url=”DispForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />
<Form Type=”EditForm” Url=”EditForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />
<Form Type=”NewForm” Url=”NewForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />
</Forms>

<Forms>

<Form Type=”DisplayForm” Url=”DispForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />

<Form Type=”EditForm” Url=”EditForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />

<Form Type=”NewForm” Url=”NewForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />

</Forms>

This section defines standard out of the box forms, and there are 3 types of forms: Display, Edit, and New.

We`ll add another line right after NewForm that will look like this:

<Form Type=”DisplayForm” Url=”PrintForm.aspx” SetupPath=”pages\MyTemplates\form.aspx” WebPartZoneID=”Main” />

What we defined above is that our form will:

1. Behave like a display form – that is all of the fields will be read only labels etc

2. Will have our custom name of PrintForm.aspx

3. Will use pages\MyTemplates\form.aspx as a template, which we define next

if you take a look at 12 hive/TEMPLATE/Pages you will find form.aspx a file which all of display, new, and edit forms look up to conform to the defined style.

If you create a new folder in your 12 hive/TEMPLATE/Pages called MyTemplates and copy the form.aspx from the parent to your new folder – you will successfully reference new template in your schema.xml definition.

In my example, since I had to create a Printer Friendly version of the display form, I removed everything from my new form.aspx and ended up with this:

<asp:Content ID=”Content1″ ContentPlaceHolderId=”PlaceHolderPageTitle” runat=”server”>

<SharePoint:ListFormPageTitle ID=”ListFormPageTitle” runat=”server”/>

</asp:Content>

<asp:Content ID=”Content2″ ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>

<WebPartPages:WebPartZone runat=”server” FrameType=”None” ID=”Main” Title=”loc:Main” />

</asp:Content>

One thing to note here is that I have my new Print.master defined at the top. This step is not required unless you want to change the look of your new form masterpage. Since my goal was a Printer Friendly view – I had to make my masterpage as simple as possible.
Here is the body of my new masterpage:
 
<BODY>
<form runat=”server”>
<WebPartPages:SPWebPartManager id=”m” runat=”Server”/>
<asp:ContentPlaceHolder id=”PlaceHolderMain” runat=”server”>
</asp:ContentPlaceHolder>
</form>
</BODY>
 
Once my master page and list provisioning features were activated, my new display form was accessible under MyList/Forms/PrintForm.aspx as I defined it in my schema.xml
 
Hope this helps in your form customizations!

Yaroslav Pentsarskyy, SharePoint MVP
Blog: www.sharemuch.com