This project is read-only.

Project Description

AreaProg Toolbox is a set of tools that will ease your development. As I develop mainly in SharePoint, a lot of tools will be related to SharePoint development.


Snippet Management (2011-27-27)

This solution add two buttons in the SharePoint Ribbon:

These two buttons are used to save and insert snippet. To save a new snippet, you have to edit the page, select text in the SharePoint Rich Text Editor, click on Save button and enter the name of the snippet:

Then, you can easily insert this snippet everywhere in the site by clicking on the Insert button:

This solution also handles the folder:

The solution contains a feature (scope : Web). When you activate this feature, the two buttons are addfed to the Ribbon and a list called "AP_SnippetsManagement" is created on the web site. This list will store all snippets for the current site.

Tested on: SharePoint 2010


Image Field (2011-07-14)

The source of "Image Field" contains a reference to "Custom Field Management", so if you are not able to compile the source or use the WSP, it is surely because you don't have to DLL of "Custom Field Management" in your GAC.

The native "Image" field in SharePoint is not very straightforward. Indeed, we first need to upload the picture in a picture library, then copy the link of the picture and finally, paste it into the image field. The "AreaProg Image Field" does all of it in on step. When you create the field, you can define in which picture library selected image will be uploaded. You can also define a pattern for the name and the behavior when there is a name conflict:

The definition of the field value is also very straightforward: 

If you add a new item, you can select previously uploaded pictures:

The edition is based on the same system. You can either upload a new picture or use an existing picture. 

Finally, if you retrieve the SPField corresponding to your image field programmatically, you can access its custom properties "PictureLibrary", "Web", "FormatName" and "Overwrite".

Tested on: SharePoint 2010 & SharePoint 2007




Custom Field Management (2011-07-12)

During the development of a SharePoint custom field, a reccurent problem occurs. Indeed, when you want to store custom properties in the field that you are creating, you could want using SPField.GetCustomProperties and SPField.SetCustomProperties. Unfortunately, these two methods don't work very well, and thus, no custom property is saved. In SharePoint 2007, we could use WSP Builder to auto generate huge amount of code to handle custom field properties. Now, when we develop a SharePoint solution with Visual Studio, the workaround is no longer implemented and the problem comes back.

With Custom Field Management, this problem will vanish easily. You can download the source code and check the example delivered with them. In this exemple, you'll see how to store custom simple property (values type) or complex custom properties (class used to store several properties).

In the end, with a few lines of code, you can easily have custom properties like this:

The steps to follow in order to obtain this kind of custom properties :

  • Create the class that inherits from SPFieldXXX
  • Override OnAdded & OnUpdated method and insert this line of code in the method body : FieldManagement<ComplexType>.SetFieldProperties(this); 
  • Create the class that inherits from IFieldEditor and bind it to the field thanks to the fldtypes_XXX.xml (custom field development basics)
  • Declare a private field with the desired type. Either value type or reference type. Let's say that this field is called "fieldProperties"
  • Implement "InitialiseWithField" method with this line of code : fieldProperties = FieldManagement<ComplexType>.GetFieldProperties(field);
  • Implement "OnSaveChange" method:
    • Create the object that will store the property value (either the value type or the class)
    • Save property with this line of code: FieldManagement<TypeOfProperty>.SaveProperties(property); 
  • In the CreateChildControl, init controls with value in "fieldProperties"

And that's it. For more info, see the example delivered with source code.

This tutorial (in french) explains what's going on behind the scenes: Not yet written...

Tested on: SharePoint 2010 & SharePoint 2007

Last edited Aug 3, 2011 at 8:03 AM by ssougnez, version 17