I've created a custom type and I would like to have a custom administration sight where a few global settings can be defined. I've done a bit of looking around but haven't found anything that shows how to do this. Can this be done in SharePoint 2010?

  • What do you mean by custom type? and how do you want to manage it? Please any examples of your settings. – Yuri Leontyev Nov 24 '11 at 10:13
  • I mean a type that I have created that is not an out of the box field type. The one in question in a modified version of the Text field type. I'd like to manage it with a custom administration page. – Abe Miessler Nov 24 '11 at 17:30

I guess it depends on how 'global' you really want to scope your global settings. I tend to think that a good boundary for your situation would be the web application.

In that case, you could store your settings in the SPWebApplication property bag.

From your global settings page, you would set the values, something like this

    //get a handle on the web application somehow
    SPWebApplication webApp = webAppSelectorControl.WebApplication;
    webApp.Properties["CustomGlobalSetting"] = "CustomGlobalValue";

You'll need appropriate rights in order to set the values, but anyone should be able to read them ok

string customSetting = (string)SPContext.Current.Site
| improve this answer | |
  • This won't necessarily work, depending on where the global settings page is run. In a least privileges configured system, the content application pool account probably won't have rights to set the values; it shouldn't have rights to the config database. The exception to this is Central Administration app pool - its account must have write access to the config database. So, the short of it - the global settings page should probably go in central admin. – Andy Burns Nov 22 '11 at 18:06
  • Agreed. A central admin page to manage the settings is what I've used before. I updated the code sample – Paul Lucas Nov 22 '11 at 22:47

From global settings, I understand the settings should be applied to all the instances of custom field type across site collection, web application or farm.

For Site Collection level : You can keep the settings for custom field type in a list.You can retrieve these settings by reading the list in code behind. Also, You can fine tune permissions on a list ( and list items), so you can manage rights who can edit the settings individually.

For Web application level or Farm level : You can define those settings in a XML file and keep it at 14\TEMPLATE\LAYOUTS folder.You can build a custom administration page which can edit\save the xml file. Many third party(KwizCom, Telerik) custom field type settings are stored this way.

If you want field settings at instance level(when you create\edit the field), you can define custom properties for it and render it on New Site Column, Change Site Column, Create Column, and Change Column pages.This link discuss about two methods to do it and how to choose correct one:

Custom Field Type Property Rendering

| improve this answer | |
  • Is this the only option for doing something like this? – Abe Miessler Nov 22 '11 at 5:06
  • Please check my edit above – Amit Kumawat Nov 22 '11 at 6:06
  • If I had to check that XML file every time the custom field type was used do you think it would be likely that I would see performance problems from all the file IO? Also, is there a special way to access that XML file once it's in my layouts folder or would I just specify the path like with any old XML file? – Abe Miessler Nov 22 '11 at 6:56
  • You can access the Xml using XMLTextReader.I don't think File IO will cause performance problem (You can also cache the XML).I have used Telerik RADEditor for SharePoint which uses same technique to load their tools file(xml) where some global settings for their custom field are defined – Amit Kumawat Nov 22 '11 at 9:48
  • If you are interested in looking implementation of Telerik Rad editor (which is also used as rendering control for custom field type in SharePoint), check this out :demos.telerik.com/aspnet-ajax/editor/examples/default/…. It uses Basictools.xml which you will see there – Amit Kumawat Nov 22 '11 at 10:10

I would prefer the solution of Paul Lucas because if you place the settings in the property bags, they get stored in your content database. Especially if you have multiple frontend servers this is mutch easier to handle... they are available on each server.

They are also easier to retrieve than in the "list solution".

Besides the webapplication you can store properties on SPSite or SPWeb level.

Using CustomActions you can also add a link to your configuration page in the site settings.

| improve this answer | |
  • 1
    Just as a note, the property bags for the SPWebApplication object are stored in the config database, as opposed to the content database. – Andy Burns Nov 22 '11 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.