Tuesday, February 8, 2011

Tip #2: SharePoint 2010 Content Type Definition

People from all areas of SharePoint always reference the uses of 'Content Types'. The best definition I can give to help people understand SharePoint Content Types is that they are SharePoint business objects in a nutshell. SharePoint uses content types for everything. They are the main building blocks for your informtion for your information architecture. Here is some example code to show you all the content types available in your sharepoint site:


         using (SPSite site = new SPSite("http://localhost:30005"))
            {
                foreach (SPContentType ct in site.RootWeb.ContentTypes)
                {
                    //Prints out each content type in your site
                    Console.WriteLine(ct.Name + " (" + ct.ParentName + ")" + ct.Id);
 
                    foreach (SPField field in ct.Fields)
                    {
                        //Prints out each column that is in that content type
                        Console.WriteLine("\t" + field.StaticName);
                    }                    
                    Console.ReadLine();
                }
            }

Hope this helps!

Monday, January 31, 2011

How to enable SharePoint Developer Dashboard in SharePoint 2010

Tip #1: Enable SharePoint 2010 Developer Dashboard

I know when working with SharePoint 2010 I need the ability to enable the developer dashboard and sometimes I don't have the code around so I just need a quick snippet to enable the dashboard. Make sure you add a reference to 'Microsoft.SharePoint.dll'. This enables the dashboard for all pages:


            SPWebService contentService = SPWebService.ContentService;
            SPDeveloperDashboardSettings developerDashBoard = contentService.DeveloperDashboardSettings;
            developerDashBoard.DisplayLevel = SPDeveloperDashboardLevel.On;
            developerDashBoard.Update();

            Console.WriteLine("Developer dashboard has been enabled.");

If you need the developer dashboard enabled on a per-page basis just change the display level property of the SPDeveloperDashboardSettings object to :


            developerDashBoard.DisplayLevel = SPDeveloperDashboardLevel.OnDemand;

I hope this helps!

Remember, if you need any custom sharepoint development or consulting please see Vorality Consulting for more information.

Friday, December 3, 2010

SharePoint 2010 Development Blog Creation

This blog will represent my journey into SharePoint 2010 Development, from concept to creation. This blog will feature many hands-on examples and give developers out there moving from SharePoint 2007 development to SharePoint 2010. I will be posting helpful tutorials, product updates, tips & tricks, video tutorials, and much more! Please visit vorality consulting for more SharePoint information and more info on our SharePoint consulting practice. Enjoy!