SharePoint 2007: Formatting a FormField

我们两清 提交于 2019-12-24 06:49:44

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/704332/sharepoint-2007-formatting-a-formfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!