Thursday, March 21, 2013

Setting Custom ListFormWebPart Parameters in List Definition

In order to set custom ListFormWebPart parameters when defining list definition schema, you need to modify Form tag in schema.xml. Please refer to the following sample, used to add CSRRenderMode property to ListFormWebPart and set it to ServerRender:

<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" UseDefaultListFormWebPart="False">
      <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="1">
<WebPart xmlns="">
  <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, 
  <CSRRenderMode xmlns="">ServerRender</CSRRenderMode>


You can change Microsoft.SharePoint assembly reference to or to use it with SharePoint 2010 or SharePoint 2007 respectfully.


  1. Is there a way to Set this property for a List using Code. I can see the enum CSRRenderMode in Microsoft documentation but not sure how to use it.


    1. CSRRenderMode property is not a List property, but ListFormWebPart property. In order to change it from code, you need to access ListFormWebPart web part (usually placed on the List form), and just change its properties.

    2. What if I add the item to the list programatically using CSOM/JSOM etc. Also does it work for other event receivers like web adding etc.

    3. It would not work whenever you do not have HttpContext. But if you do, theoretically it should work. Never tried it like this though.

  2. when i add Your code ai have this error message:
    Severity Code Description Project File Line Suppression State
    Warning The element 'Form' in namespace '' has invalid child element 'WebParts' in namespace ''. List of possible elements expected: 'ListFormOpening, ListFormBody, ListFormButtons, ListFormClosing' in namespace ''. POLKOMTEL_PowiadomieniaAD