SharePoint 2010 OOTB Features
The following are the features installed by SharePoint 2010 Enterprise. I frequently need to find what a feature is associated with a feature id during development, and hence the table.
As all feature titles and descriptions are localized, I have extracted the localized strings for each of the strings from english langauge installation.
Hope this helpful.
Create a SharePoint 2007 publishing page programmatically
This is a simple code to create a SharePoint (MOSS) 2007 Publishing page with code. Hope this helps
// Get the SPSite - getting the current site for examples sake
SPSite cursite = SPContext.Current.Site;
using (SPWeb curweb = cursite.OpenWeb())
{
// Get the Pages library of the web
SPList pagelist = curweb.Lists["Pages"];
//content type assigned to the pages library
SPContentType contentType = pubSite.ContentTypes["ContentType Name"];
//page layouts for the content type
PageLayoutCollection pageLayouts = pubSite.GetPageLayouts(contentType, true);
Dictionary<string, PageLayout> dPageLayouts = new Dictionary<string, PageLayout>();
foreach (PageLayout pageLayout in pageLayouts)
{
dPageLayouts.Add(pageLayout.Title, pageLayout);
}
//page layout that is required for the new page
PageLayout pageLayoutToUse = dPageLayouts["layoutName"];
//publishing web from the currently open web
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(curweb);
//add a new page
PublishingPage newPubPage = pubWeb.GetPublishingPages().Add("newPageName.aspx", pageLayoutToUse);
//put what ever content you want in the page.
SPListItem newPage = newPubPage.ListItem;
newPage["Title"] = "New Page Title";
newPage["content"] = "<span><b>here's some new content</b></span>";
newPage.Update();
//check the file in and publish it
newPage.File.CheckIn("Autocreated");
newPage.File.Publish("Autocreated");
try
{
//This will throw an exception if Approval is not enabled on the pages library
newPage.File.Approve("Autocreated");
}
catch
{
}
}
70-542 Study Resources
This is the collection of resources I have gathered over the course of my preparation for the Microsoft Exam 70-542.
The primary reason for collection this information is that there is no comprehensive resource for this exam available on the net, unless one opts for a paid resources. After working more or less exclusively on SharePoint 2007 for last 2 years, I see no reason for me to go for paid resources. Most things are already available on MSDN and hundreds of blogs.
If you have any resource you want me to include here, do not hesitate to post it in the comments and I will include it (of course with attribution) in the guide.
Get File Sizes of Document from Sharepoint Database
This is a simple query to get file sizes from a sharepoint database. I know there are multiple ways of doing this, but I found this the easiest and also the fastest.
select [filename],
sum(CAST((CAST(CAST(filesize as decimal(38,2))/1024 As
decimal(38,2))/1024) AS Decimal(38,2))) AS 'Size in MB'
from (
select dirname + '/' + leafname as [filename],
size as filesize,
siteid,
webid,
ExtensionForFile
from alldocs
union
select d.dirname + '/' + d.leafname as [filename],
v.size as filesize,
d.siteid,
d.webid,
ExtensionForFile
from alldocs d
inner join alldocversions v on d.siteid = v.siteid
and d.id = v.id
) as results
inner join webs s on s.siteid = results.siteid
and s.id = results.webid
where (filesize is not null
and filesize > 0)
and ExtensionForFile not like '%aspx%' -- Not Include Certian File Types
group by
[Filename]
order by 2 desc
Add choices to Sharepoint Multi-Choice Field
Setting field values of a list item in SharePoint is easy. But when it comes to Multi-Choice fields, the code is a big different. The following code shows how values can be added to a multi-choice field.
SPFieldMultiChoice choiceField = (SPFieldMultiChoice)myWeb.Fields["choiceFieldName"];
choiceField.Choices.Add("Value");
//Set PushChangesToLists to true if automatic update of List or Content types is required
choiceField.PushChangesToLists = false;
choiceField.Upate();