Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

How do i dynamically specify the document library, in a synchronous event?

$
0
0

In trying to dynamically detect the document library a user has selected and working in, I did this previously within an ItemAdded event like the code below.

SPWeb currentWeb = properties.Web;
SPListItem listItem = properties.ListItem;
SPList myList = listItem.ParentList;
SPFolder mylibrary = myList.RootFolder;

How do I get the same thing done in an ItemAdding event? I am assuming because ItemAdding  a synchronous event, that has something to do with why the same approach doesn't work. How do I get to do the same thing in ItemAdding event? What I am trying to accomplish is this...when a user uploads a document into a document library, I want to use an ItemAdding event to ask the user for some metadata input before the document is added to the library. To get this done, i want to dynamically detect what document library they are uploading the document into. 

If I tried to use the same idea as I did above, I get a NullReferenceException (Object reference not set to an instance of an object.) at this point

SPList myList = listItem.ParentList;

How do I get this done? I really appreciate the help...

Thanks


Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>