Get document name in a DispForm
-
03-10-2020 - |
Domanda
I'm working with a document library and i want to customize the Forms. I need to show the document name in the DisplayForm but the following doesn't work:
<xsl:value-of select="@Name"/>
I also tryied
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Display" FieldName="Name" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Name')}"/>
but i get a correlation with Error The variable or parameter 'Pos' is either not defined or it is out of scope.
how do i get the name?
Soluzione
To get the document name in your custom display form try this, it worked for me.
<tr>
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
<nobr>Name</nobr>
</H3>
</td>
<td>
<CustomTemplate>
<SharePoint:FormField ControlMode="Display" FieldName="LinkFilename" DisableInputFieldLabel="true" runat="server"/>
</CustomTemplate>
</td>
</tr>
Place the above code below your Title field appropriately through design view in SPD. I have also added a new field "Author" (i.e. Created By) by simply copying the above code and replacing FieldName="Author".
Here is my output:
To get document name via XSL variable:
<tr>
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
<nobr>Name</nobr>
</H3>
</td>
<td width="400px" valign="top" class="ms-formbody">
<xsl:value-of select="@FileLeafRef"/>
</td>
</tr>
Altri suggerimenti
The name column actually has a different internal name. You can use LinkFilename to reference the name column.