Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a document library. I want to add an itemadding event recieiever to do some validation on the file name of the document. How can I get the file name from the SPItemEventProperties

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

The ListItem is not available in ItemAdding. This won't work.

share|improve this answer
add comment

You can use

Properties.AfterUrl

and then split it by "/" and get the second part of string to get document Name, it does work for item adding or item updating.

share|improve this answer
add comment

You need to use SP.ListItem.get_file();

SP.ListItem.file A sample code is mentioned here

share|improve this answer
    
I thought ListItem was null on the ItemAdding Event? –  John Jul 16 '12 at 13:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.