Windows SharePoint Services 3.0 provides a versioning capability that
prevents documents from being overwritten by creating a version of the
file each time a change is made to either the file or the metadata.
However, there may be specific situations, such as archival or
records-management scenarios, in which you want to let users modify
metadata but not modify the file contents; that is, there is always only
one version of the file. This Microsoft Office Visual How To shows how
you can enable this in specific scenarios by using event handlers and
handling short-term and long-term check-outs.
Showing posts with label Sharepint prevent file deletion. Show all posts
Showing posts with label Sharepint prevent file deletion. Show all posts
Friday, November 18, 2011
Thursday, September 22, 2011
Event Handler to prevent deletion of document from document library
- Start Microsoft Visual Studio 2010.
- On the File menu, point to New, and then click Project.
- In Project Types, under Visual Basic or C#, select Event Receiver.
- Type <Name for your project > as the project name. Click OK.
- In the SharePoint Customization Wizard, choose Deploy as a farm solution. Click Next.
- In the Choose Event Receiver Settings dialog, select List Item Events in the What type of event receiver do you want? choose from drop down dropdown.
- In the What item should be the event source? choose from dropdown, choose Tasks.
- Choose the An item is being deleted option in the Handle the following events list. Click Finish.
- In the EventReceiver1 file that is created, insert the following code in the ItemDeleting method.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace EventHandler
{
class AnnouncementDeleteRevert: SPItemEventReceiver
{
public override void ItemDeleting(SPItemEventProperties properties)
{
string errorMessageToDisplay= ("Announcements can not be deleted from this list");
properties.ErrorMessage = HandledMessage;
properties.Cancel = true;
//or
properties.Status = SPEventReceiverStatus.CancelWithError; properties.ErrorMessage = "Deleting items from " + properties.RelativeWebUrl + " is not supported.";}
}
}
Subscribe to:
Posts (Atom)
Featured Posts
Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP
Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...
-
public struct CoOrds { public int x, y; public CoOrds( int p1, int p2) { x = p1; y = p2; } }
-
LM Studio Overview LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs)...