Skip to content

November 21, 2007

SPFileCollection.Add(string, Stream, Hashtable)

If you’re using one of the SPFileCollection overloads to create a file in SharePoint you’ll find that there’s a few overloads that take in a Hashtable for properties.  The key of the Hashtable can not be the GUIDs for the fields, they should be the internal names of the fields.

SPContentType.Fields and SPContentType.Parent

A few random observations about SPContentType…

.Fields — This isn’t a complete collection of fields as it might be on SPList.  It’s just the fields that are directly added to the content type.

.Parent — This won’t return you a null if there are no parents to this content type.  Instead it keeps returning you the same content type.  So rather than doing what you would normally do — SPContentType.Parent == null — to test to see if you’re at the top content type, you must check SPContentType == SPContentType.Parent.  (or add .Id to each of these to make sure that you’re getting an equality comparison rather than a reference comparison.)

You may notice that some of the core fields for SharePoint items aren’t represented anywhere in the hierarchy (Author, Editor, Created, and Modified were the ones I noticed).

A final note is that even if a content type is activated in a site collection you may not be able to get to it from the SPWeb object of the current web site, so you get to walk the tree up to the root site in the site collection and pickup the reference from there.  Of course, you don’t want to add it to the current SPWeb object because you’ll get an error about a duplicate object.  (Apparently it exists, you just can’t retreive it.)

Article: Understanding SharePoint Branding Options

When we’re talking about branding in Microsoft SharePoint there are several options. You’ve probably heard about site definitions, site templates, themes, master pages, page layouts, CSS, and so on. In this article we’ll tear apart each of these options and discuss what you’ll want to use to modify the appearance of your pages.

http://www.intranetjournal.com/articles/200711/ij_11_20_07b.html [Website removed]

Recent Posts

Public Speaking