I have a display form of an external list generated by sharepoint designer 2010. The editable webpart has this code:

<WebPartPages:XsltListFormWebPart runat="server" Description="" FrameType="Default"   
PartOrder="2" HelpLink="" AllowRemove="True" IsVisible="True" ViewGuid=""
AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="False"DataSourceID="" Title="" ZoneID="Main" ViewFlag="0" FormType="4" AllowConnect="True" PageType="PAGE_DISPLAYFORM" FrameState="Normal" CatalogIconImageUrl="/_layouts/images/itebl.png" PageSize="-1" PartImageLarge="/_layouts/images/itebl.png" AsyncRefresh="False" ExportMode="NonSensitiveData" Dir="Default" DetailLink="/datamining/Lists/ForecastJob Activity Monitor" ShowWithSampleData="False" ListId="1c98d95a-d87c-4b66-9989-10dadb1a824e" ListName="{1C98D95A-D87C-4B66-9989-10DADB1A824E}" PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" ControlMode="Display" ManualRefresh="False" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True" WebId="00000000-0000-0000-0000-000000000000" ViewContentTypeId="" EnableOriginalValue="False" InitialAsyncDataFetch="False" GhostedXslLink="formxml.xsl" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" ID="g_686bd8ac_4b09_4950_a4e4_e5938240d45d" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" TitleUrl="/datamining/Lists/ForecastJob Activity Monitor" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{686BD8AC-4B09-4950-A4E4-E5938240D45D}" WebPart="true" Height="" Width=""><ParameterBindings>

<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
    <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
    <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
    <ParameterBinding Name="ListItemId" Location="QueryString(ID)" DefaultValue="0"/>

<UserControl x:Class="FormXmlToXaml.UserControl2" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:system="clr-namespace:System;assembly=mscorlib"><StackPanel x:Name="Form">
<system:String x:Key="FormMode">Display</system:String>
<system:String x:Key="FormType">ListForm</system:String>
<StackPanel x:Name="MainSections"><Grid><Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource ms-formlabel}"/>
<ColumnDefinition Style="{StaticResource ms-formbody}"/>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="0" ControlMode="Display" FieldName="Process" />
<Comment FieldName="Process" FieldInternalName="Process" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="0" ControlMode="Display" FieldName="Process" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="1" ControlMode="Display" FieldName="Store" />
<Comment FieldName="Store" FieldInternalName="Store" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="1" ControlMode="Display" FieldName="Store" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="2" ControlMode="Display" FieldName="StartDate" />
<Comment FieldName="StartDate" FieldInternalName="StartDate" FieldType="DateTime" />
<SharePoint:FormField Grid.Column="1" Grid.Row="2" ControlMode="Display" ID="ffStartDate" FieldName="StartDate" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="3" ControlMode="Display" FieldName="EndDate" />
<Comment FieldName="EndDate" FieldInternalName="EndDate" FieldType="DateTime" />
<SharePoint:FormField Grid.Column="1" Grid.Row="3" ControlMode="Display" FieldName="EndDate" IncludeDescription="True"/>

I would like to use a xsl style to format the form field with the ID "ffStartDate". How is this possible?


Unfortunately, SharePoint forms (for both external and regular lists) do not support XSLT rendering for the internals of the fields. You can arrange fields via XSLT, split fields to tabs, group them and so on, but the field controls are rendered by server controls "FormField", and that's that.

XSLT rendering of the fields is supported only for list views.

This is admittedly a very unfortunate limitation. In SharePoint 2010, there were two major approaches to change rendering of the fields in a list:

  1. Create Custom Field Types
  2. Use javascript/jQuery hacks

In SharePoint 2013, we now also have Client Side Rendering, which is essentially a supported way of doing javascript/jQuery hacks :)

Custom Field Types involve C# development, and since you're using SharePoint Designer, I anticipate you would avoid that.

So for you, solution would be to use javascript/jQuery hacks in SP2010 (e.g. you might want to consider SPServices Opensource js library, which already includes implementation for most common requirements) and Client Side Rendering in SP2013 (examples can be found on MSDN).

| improve this answer | |
  • Hi Andrey, thanks for your answer. I would like to embed javascript/jQuery in the form but this seems not so easy. Do you perhaps have useful links or info how to accomplish that? – AGuyCalledGerald Mar 5 '13 at 11:35
  • Simplest way would be to add Content Editor WebPart (CEWP) to the form page. Provide link to a txt file as a source for the CEWP, and add <script type="text/javascript">.... and so on to this txt file. You can do it even from browser. Alternatively, you can open form in SharePoint Designer (Lists and libraries => (your list) => Forms => EditForm.aspx) and add js to the page. Also, SPServices project contains comprehensive documentation on this topic (please follow the link provided in the answer). – Andrey Markeev Mar 5 '13 at 13:14

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.