3

I'm working on a SharePoint 2013-Solution which deploys a custom list with custom site columns and a custom form. In the list's Schema.xml I added following lines:

<Forms>
  <Form Type="DisplayForm" Url="DisplayVisitor.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Visitors\DisplayVisitor.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditVisitor.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Visitors\EditVisitor.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewVisitor.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Visitors\NewVisitor.aspx" WebPartZoneID="Main" />
</Forms>

Inside the NewVisitor.aspx, I have a DataFormWebPart which XSL definitions etc. In general, I followed the description on this article: http://www.ilikesharepoint.de/2013/11/sharepoint-create-custom-list-forms-with-visual-studio-part-2/

The deployment works and the form is successful loaded when adding a new item, but after my DataFormWebpart, which is displayed the way it should, the default list form with all other columns is added automatically.

Default form is added after the custom DataFormWebpart

When inspecting the page, I can confirm that a second webpart is added automatically during deployment, but this should not happen. HTML inspection

How can I prevent SharePoint to add a default list form to the page, so that my defined DataFormWebpart is the only one form which is displayed?

Thank you for help!

1

I was able to use a custom form in place of the default one, without duplicated fields by applying the attribute

UseLegacyForm="TRUE"

on my custom form registration. In your case that should become:

<Forms>
  <Form UseLegacyForm="TRUE" Type="DisplayForm" Url="DisplayVisitor.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Visitors\DisplayVisitor.aspx" WebPartZoneID="Main" />
  <Form UseLegacyForm="TRUE" Type="EditForm" Url="EditVisitor.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Visitors\EditVisitor.aspx" WebPartZoneID="Main" />
  <Form UseLegacyForm="TRUE" Type="NewForm" Url="NewVisitor.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Visitors\NewVisitor.aspx" WebPartZoneID="Main" />
</Forms>

I would try to do the same, but I don't exclude there is a more appropriate way. That said, most of the tutorials I am aware of suggest this approach, so it is worth a try.

1
  • Now I get a UnsafeControlException: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe. Looks like it would work, but my DataFormWebpart does not work "alone"... – Fensterbank Dec 1 '14 at 15:59
1

I found a Solution for this case. While using the attributes

UseDefaultListFormWebPart="FALSE"

or

UseLegacyForm="TRUE"

did not add the default form webpart, SharePoint threw an UnsafeControlException. It looks like the DataFormWebpart on my NewVisitor.aspx could not be used "standalone" this way.

The final solution was following:

  1. Open SharePoint Designer and add a new form xslt webpart
  2. Replace its content with my DataFormWebpart from NewVisitor.aspx
  3. Remove my DataFormWebpart from ZoneTemplate of NewVisitor.aspx
  4. Select the WebPart and save it as .webpart file with the ribbon button
  5. Open it in text editor and insert the webpart definition to Schema.xml

enter image description here

1
  • will double-check my original code, I will let you know shortly. – SPArcheon Dec 2 '14 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.