Part 1: Introducing Multiple Attachment Custom Control in Sharepoint

First question you may want to ask is, why do I need a multiple attachment custom control for Sharepoint while Sharepoint already have its own attachment control that exists in the Sharepoint lists by default?

My answer is:

1. Sharepoint multiple attachment control will allow you to change names of the documents on the fly when you upload them instead of using default names.

2. We can't check about the extensions we are uploading.

3. We cant limit the number of files going to be uploaded, ( the simplest scenario; that we have 500 user on the site if each one uploaded 10 files, each of 2 mega bytes so we will have 500 * 10 * 2 = 10,000 mega byte , so we must limit the number of uploads the user could make).


4. All the previous points could be the basic needs to make a multiple attachment custom control, but we can also add much more capabilities to the uploading control.

We need to declare the algorithm of our control :


1. First you must know about how to create custom controls, you can check this URL:

http://sptechytalks.blogspot.com/2009/08/how-to-create-sharepoint-custom-fields.html

2. Put in your mind that all we will need to think about the both cases we will need to handle , Addition Mode and Edition Mode we need to put these modes in our mind all over the process of creating this control.

3. How to add a file ?

We will add a guid Id that represents the added file and also we will add a guid id to the item that we add the attachment to it. That means there are two IDs , one for the Main Item , and another guid id for each item will be uploaded belonging to this item.

4. What is the way to add these files ?

each file when uploaded will be added to the document library that contains the files with the same type , the name of the file will be the Guid id representing this file , and the Title of it will be ( its name + * + Guid ID of Item the uploaded file belongs to )


5. How to Delete the files ?

Just go to the specific document library and remove the guid id of the Item from the uploaded file you want to delete.

All the difficulty we will face is how to maintain the stability or the state of our item and its uploaded files in both cases add and edit modes.

We must also take in consideration all the following scenarios ;

a. Adding file and assign the Main item to the uploaded file (working with Guid Ids).

b. Deleting the file and its association Id.

c. also both previous actions in the Edit Mode.

d. also must take in consideration the types and extensions you will provide and how to stop uploading when the limit entered by the user for a certain type is exceeded.

There are many other scenarios that we must take in consideration. We will see them later in my forthcoming posts.

See Part 2: Starts development - Layout creation
Ebook Download
View all
Learn
View all