Friday, August 31, 2012

Custom Web Part to Add document to SharePoint document library

I am categorizing this post into two parts. First part is just to make foundation for this post.


To display files and folders of a document library in a tree view style you will need to create a custom web part and for that, you can always refer this link:

Now, let's come to the second part which is also the focus of this post.


Now suppose, you need to add a document from above web part while refreshing the tree view at the same time.

Given below is the code to achieve this:

Code Description:
a.) Get document library permission level for logged in user so that 'Add Document' link can be hidden for less privileged users.
b.) Put 'Add document' link on web part with SharePoint look and feel. On clicking, it calls a java script function which is registered using 'RegMyScript'.
c.) It adds document to document library in the SharePoint way and also refreshes library tree view to show the newly uploaded document.

Code Download Link.

No comments:

Post a Comment