As I mentioned in my earlier blog item “Custom Picker Control” that I am going to post information on replacing OOB people picker with a custom people picker with custom data source. Here is the information.
Integration of custom people picker control with site definition
· The custom people picker control cannot be integrated with the custom site definition. The OOB people picker control has been used in several application pages (Layout pages) which cannot be replaced just by integrating the control with the site definition.
· Moreover in Sharepoint site definitions it’s not possible to integrate any control to replace the OOB controls
Customizing the Application Pages to replace the OOB people picker control with the custom people picker
· There are several application pages in which the OOB people picker control is used. For Ex peoples.aspx, Groups.aspx, aclinv.aspx… etc. The workflow pages also reside under the application pages category.
· If you want to replace the people picker in these pages you need to create custom application pages by copying the respective OOB pages and need to replace the OOB people picker with the custom people picker control.
· To redirect the users to your custom application pages you will end up in customizing the navigation.
· When you are replacing the control then you need to change the code behind for the server related events of the pages so that the sharepoint reads data from your custom control and does not look for the OOB people picker control. Unfortunately, we can't disassemble Microsoft.Sharepoint.Applicationpages to read MS mind. :(
· It is going to be big development effort depends on how many custom application pages you creates to implement the custom people picker control.
Customizing the Item form pages (NewForm.aspx, EditForm.aspx, DispForm.aspx… Etc) with the custom people picker
· The most critical part of replacing the custom people picker comes with customizing the item form pages. Unlike the other application pages item form pages are rendered dynamically and the number of fields and the controls related to the list is determined dynamically on the ply when the item was created. These item form pages are having the form.aspx page as the parent page under the 12/Templates/Pages folder. In this Forms.aspx page the web part zone is empty and the “ListformWebpart” is rendered dynamically when we create the item in the List. This relation between the form.aspx page and the ListformWebPart is mentioned in the schema.xml file of the List definition. Adding a task item is an example in this scenario.
· So it’s not going to be possible to just replace the OOB people picker control with the custom people picker control.
· The easiest way to render the custom people picker control in the item form pages is to ghost the pages through sharepoint designer and can create custom item form pages with the required control but the control will be available only in the site level not under the sharepoint farm level. It will increase the effort to customize the item form pages for the every site you create in the sharepoint farm.
Finally to implement the custom people picker control across the sharepoint farm you need to implement the following steps
· Create the custom field type and render the custom people picker control as the field rendering control for the custom field type.
· Create a custom feature to register a “Site Column” of your custom field type created in the step a.
· Create a custom feature to create a custom content type. Create the custom content type inheriting from any of the OOB content type, for example if you want to replace the “Assigned To” field control of Task list with the custom people picker control then create the custom content type based on the OOB content type “Task”. Use the “RemoveFieldRef” attribute to remove the “Assigned To” field from the parent content type and add the new field reference of your custom field type (Site Column).
· Now your custom content type is available with the custom Assigned To field which render the custom people picker control as the field is created based on the custom field type.
· Again the code behind of the “Save Button” in the item form pages looks for the OOB Assigned To field and it will fail to locate one.
· So you need to create the custom save button and need to replace the button through the sharepoint rendering template.
· You need to create the custom Sharepoint Rendering template through customdefaulttemplates.ascx (By copying the “ListForm” rendering template from the defaulttemplates.ascx) control under the controltemplates folder. Need to replace the “SharePoint:SaveButton” with the custom save button in the custom rendering template.
· The custom rendering template can be mentioned through the custom content type via the “XMLDocuments” tag.
· Create the custom list definition and render the custom content type for the list definition