Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event handler

Status
Not open for further replies.

markd85

Technical User
Nov 1, 2010
11
GB
Hi is there a way I can disable viewing of files that have been checked out?

We have a number of users on office 2003 and although the file when open is read only it doesn't tell the user this.

I have attempted an event handler to accomplish this but it doesn't work

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace MyEventHandler
{

public class ItemUpdatingHandler : SPItemEventReceiver
{

public override void ItemUpdating(SPItemEventProperties properties)
{
base.DisableEventFiring();
try
{
SPFile file = properties.ListItem.File;
if ((file.CheckOutStatus == SPFile.SPCheckOutStatus.LongTerm) ||
(file.CheckOutStatus == SPFile.SPCheckOutStatus.LongTermOffline))
properties.ErrorMessage = "This file is locked for editing, please try again later " + properties.ListItem.File;
}
catch { }
finally
{
base.EnableEventFiring();
}
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top