Question

I'm trying to display the page owner and last modified date on the footer of a SharePoint master page for a publishing site. On my master page I currently have:

<SharePoint:FormattedString FormatText="Page owner: {0} Last updated: {1:dd/MM/yyyy}" runat="server">
<SharePoint:FormField ControlMode="Display" FieldName="PublishingContact" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:FormField ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server" />
</SharePoint:FormattedString>

This works great, however it doesn't modify the date format:

Page owner: litwareinc\treesj Last updated: 3/31/2009 10:32 PM

I'm guessing the date is returned as a string so the formatting of dd/MM/yyyy does nothing. I realize modifying the regional settings on the web application might fix this however I'm more interested in how this could be implemeneted with a different format to the default.

Thanks in advance!

Jonny

Was it helpful?

Solution

You are correct - the FormField control has already rendered the output as a string so wrapping it inside FormattedString won't work.

An alternative to Nat's answer is to write your own control and wrap the FormFields within that. You can then capture the rendered output and transform as you wish.

OTHER TIPS

You really want to place a <SharePointWebControls:DateTimeField/> See here. But this is SharePoint so also see here to add some code behind to render in a different format with a little code behind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top