I'm currently deploying a SharePoint solution with publishing pages. These pages allow the user to select "Do not update the modified-date".
This is solved by a small controll placed on the page.<ctrl:ModifiedFieldManager FieldName="Modified" runat="server" id="modifiedmanager">
</ctrl:ModifiedFieldManager>
This control creates a checkbox the user can check or not.
If checked the modified field should stay the same. The control derives from "BaseFieldContr开发者_运维百科ol".public override void UpdateFieldValueInItem()
{
base.EnsureChildControls();
if (this.ModifiedFieldManagerBox.Checked)
{
this.Value = this.Item["Modified"];
base.UpdateFieldValueInItem();
}
else
{
this.Value = DateTime.Now;
}
}
The code above is responsible to write the "old" Modified-Date back to the item if checked.
The funny thing about this code is - it works if I'm logged in as admin. As a normal user this code gets executed but the modified date is still the current date and time.
Could anyone give me some advice how to solve this for normal users?
Thx in Advance
Steve
Generally, you use SystemUpdate to ensure the modified fields are not changed on teh SPListItem
More info
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.systemupdate.aspx
精彩评论