问题
I would like to force users to add their comments before checking-in document. When a user selects Check-in, the default popup page will show in order to select version and write comments, but comments field is not mandatory, can we make it as a required field??
回答1:
You could do it via EventReceiver:
public class EventReceiver1 : SPItemEventReceiver
{
public override void ItemCheckingIn(SPItemEventProperties properties)
{
base.ItemCheckingIn(properties);
string comment = (string)properties.AfterProperties["vti_sourcecontrolcheckincomment"];
if (string.IsNullOrEmpty(comment))
{
properties.ErrorMessage = "Comment empty";
properties.Cancel = true;
}
}
}
来源:https://stackoverflow.com/questions/9715038/sharepoint-2010-document-library-versions-comment