Adding a Ribbon to SharePoint 2010
If you take a look to HOL10 - Developing SharePoint 2010 User Interface Ribbon and Dialog Customizations: http://www.microsoft.com/downloads/details.aspx?FamilyID=c010fc68-b47f-4db6-b8a8-ad4ba33a35c5&displaylang=en you will notice that this Hands on Lab will not work for the public beta. If you want to follow this lab and make it work, please update your elements.xml to the next code:
<?xml version="1.0" encoding="utf-8"?>
<!-- also take a look at: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Hello_world"
RegistrationType="List"
RegistrationId="101"
Location="CommandUI.Ribbon"
Sequence="5">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button
Id="Ribbon.Documents.New.DemoHelloWorldButton"
Alt="Hello World Ribbon Button"
Sequence="5"
Command="Demo_HelloWorld"
Image32by32="_layouts/images/YourProject/YourImage.jpg"
LabelText="Hello World Demo"
TemplateAlias="o1"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Demo_HelloWorld"
CommandAction="javascript:alert('Hello World!');" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
[/code]
You can view this Ribbon if you navigate to the Documents Folder. If you want to make a Ribbon visible on other places (e.g. page which actually is a WikiPageTab) take a look to this file: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML in your SharePoint root. In the CMDUI.XML you can find the definitons of the default Ribbons which could be helpfull to extend it with your own. E.g. you can find group ID's and sequences of the Ribbons.
If you want to extend the SiteActions menu you can take a look at the next elements.xml code
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="UserInterfaceCustomActions.SiteActionsToolbar"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="MY SITE ACTIONS BUTTON">
<UrlAction Url="javascript:alert('Hello World!');"/>
</CustomAction>
</Elements>
Add an assembly to your Visual Studio 2010 SharePoint Package
If you are familiar with WSP-builder for development with SharePoint 2007, the way of adding assemblies to your SharePoint 2010 project is a little different. You always start with an empty SharePoint project. From here you can add other items. In WSP-builder you had the bin and GAC folder in Visual Studio.
To add an assembly to your Visual Studio 2010 SharePoint Package (SharePoint 2010)
- Open you Package.package file.
- On the bottom of the window you can choose: Design | Advanced | Manifest
- Choose Advanced
You can choose for an excisting assembly or the output assembly of your project.
You can deploy the assembly to the GAC (C:\Windows\Assembly - The Global Assembly Cache, full trusted) or the WebApplication (actually the Bin Folder of your WebApplication in your InetPub folder of your WebServer).
Turn Developer Dashboard on or off in SharePoint 2010
You can turn the Developer Dashboard on or off by using the next .bat file. Make sure you run this file as administrator. Otherwise a message "access denied" will be shown.
ECHO ON
SET STSADM="C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\bin\stsadm"
REM ----- Choose one of this three commands -----
REM ----- Turn Developer Dashboard ondemand -----
%STSADM% -o setproperty -pn developer-dashboard -pv ondemand
REM ----- Turn Developer Dashboard on -----
%STSADM% -o setproperty -pn developer-dashboard -pv on
REM ----- Turn Developer Dashboard off -----
%STSADM% -o setproperty -pn developer-dashboard -pv off
pause
Installing SharePoint 2010 on Windows 7
Installation Guide
A nice feature of SharePoint 2010 (Foundation and Server) is that you can install a single server environment on Windows 7. Waning, only use this type of installation for development purposes. After downloading a copy of SharePoint 2010 (beta at the moment) from e.g. MSDN you can’t directly install it on Windows 7. If you try to run the installer as administrator you get a message like: “Setup is unable to proceed due to the following error(s): This product requires Windows Server 2008 (x64). Correct the issue(s) listed above and re-run setup.”
To install it on Windows 7 you have to follow the next steps:
-
Copy the installer to your harddrive of installation (e.g. C:\sharepoint)
-
Rename the installer to spinstaller.exe
-
Extract the installation files by opening a Command Prompt (Run > CMD)
-
Type: C:\sharepoint\spinstaller /extract:c:\sharepoint
-
This will extract the installer
-
Navigate in your Windows Explorer to: c:\sharepoint\files\setup\config.xml
-
Edit this file in notepad and add the next line <Setting Id="AllowWindowsClientInstall" Value="True"/> just before the </Cofiguration> tag (Case sensitive)
-
Save the configuration file
-
Make sure the next Windows Features are turned on (Control Panel > Turn Windows Features on or off):
//You can do this quickly by copying and running the following command in a Command Prompt window.
//The following text contains line breaks. You must remove the line breaks to run this script from a command prompt.
start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;
IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;
IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;
IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;
IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;
IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;
IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;
IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;
IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;
WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;WCF-NonHTTP-Activation
-
Install SharePoint 2010 by running c:\sharepoint\setup.exe as administrator
-
Choose the installation you want: Standalone (Installs SQL Server Express)
-
After the installation is complete you, will be prompted to start the SharePoint Products and Technologies Configuration Wizard. Before starting the wizard, first install the Microsoft SQL Server 2008 KB 970315 x64.
-
-
After the Microsoft SQL Server 2008 KB 970315 x64 installation is finished, complete the wizard. If it is closed you can find it in your start menu.
-
Note: you can even install SharePoint 2010 on Windows Vista. Please visit http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx for more information.
Trouble Shooting
- If the configuration wizard breaks at step 2, showing the next error message: "System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified." a dll of the Geneva Framework is missing. Please install this framework containing the DLL and run the wizard againg. The next link contains the right dll: Download Geneva Framework.
- If the configuration wizard breaks at step 8, showing the next error message:
The WCF-NonHttp-Activation Windows Feature isn't checked. If you followed the tutorial on MSDN: http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx and didn't use the script but cross checked the features with the screenshots in the article, you missed this feature. Activate it (command prompt: start /w pkgmgr /iu:WCF-HTTP-Activation;WCF-NonHTTP-Activation;) or by Control Panel > Programs > Turn Windows Features on or off.
Download SharePoint 2010 Public Beta now
Today the public beta of Office 2010, SharePoint Server 2010, Visio 2010, Project 2010 and Office Web Apps is announced for customers and partners. You can download the beta at http://www.microsoft.com/2010. Or directly from your MSDN Subscribtion download page: http://msdn.microsoft.com/en-us/subscriptions/cc137115.aspx
If you didn't know already SharePoint 2010 (twenty-ten) is x64 only. If you are a favourite of Virtual PC 2007 you can't load x64 guest operation systems. Please use HyperV, VMWare or VirtualBox instead.
In 2010 we use new names:
WSS 4.0 = SharePoint Foundation 2010
MOSS = SharePoint Server 2010
14-hive = Root
SharePoint 2010 system requirements: http://technet.microsoft.com/en-us/library/cc262485(office.14).aspx
Site Storage WebPart
For SharePoint site Administrators it could be important to view the storage of a SiteCollection (and subsites). However, SharePoint sites are often hosted by a external hosting and administrators have no access to the Central Administration. I wrote the following WebPart which summarizes the storage of a SiteCollection and the SubSites of this SiteCollection. Since there's no property for getting the Site Size I make recursively use of the Folder Size of a SPWeb.
public class SiteUsageWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
public SiteUsageWebPart()
{
}
private SPSite siteCollection;
private SPWeb site;
private SPWebCollection sites;
protected override void CreateChildControls()
{
siteCollection = SPContext.Current.Site;
site = SPContext.Current.Web;
sites = siteCollection.RootWeb.Webs;
}
private long GetWebSize(SPWeb web)
{
long total = 0;
foreach (SPFolder folder in web.Folders)
{
total += GetFolderSize(folder);
}
foreach (SPWeb subweb in web.Webs)
{
total += GetWebSize(subweb);
subweb.Dispose();
}
return total;
}
private long GetFolderSize(SPFolder folder)
{
long folderSize = 0;
foreach (SPFile file in folder.Files)
{
folderSize += file.Length;
}
foreach (SPFolder subfolder in folder.SubFolders)
{
folderSize += GetFolderSize(subfolder);
}
return folderSize;
}
private double ConvertBytesToMegabytes(long bytes)
{
return (bytes / 1024f) / 1024f;
}
protected override void Render(HtmlTextWriter writer)
{
writer.WriteLine("<table>");
// Size of the Rootweb
writer.WriteLine("<tr>");
writer.Write("<td><B>" + SPEncode.HtmlEncode(siteCollection.RootWeb.Title) + " (RootWeb)</B></td>");
writer.Write("<td>" + siteCollection.RootWeb.Url + "</td>");
writer.WriteLine("<td>" + SPEncode.HtmlEncode(ConvertBytesToMegabytes(GetWebSize(siteCollection.RootWeb)).ToString("0.00")) + " MB</td>");
writer.WriteLine("</tr>");
foreach (SPWeb subSite in sites)
{
writer.WriteLine("<tr>");
writer.Write("<td><B>" + SPEncode.HtmlEncode(subSite.Title) + "</B></td>");
writer.Write("<td>" + subSite.Url + "</td>");
writer.WriteLine("<td>" + SPEncode.HtmlEncode(ConvertBytesToMegabytes(GetWebSize(subSite)).ToString("0.00")) + " MB</td>");
writer.WriteLine("</tr>");
//SPListCollection lists = subSite.Lists;
//foreach (SPList list in lists)
//{
// writer.Write(SPEncode.HtmlEncode(list.Title)
// e.g. you can also summarize list sizes
//}
}
// Total Size of SiteCollection
writer.WriteLine("<tr><td>-----</td><td>-----</td><td>-----</td></tr>");
writer.WriteLine("<tr>");
writer.Write("<td><B>Total size of sitecollection </B></td>");
writer.Write("<td>" + siteCollection.Url + "</td>");
writer.WriteLine("<td><B>" + SPEncode.HtmlEncode(ConvertBytesToMegabytes(siteCollection.Usage.Storage).ToString("0.00")) + " MB</B></td>");
writer.WriteLine("</tr>");
writer.WriteLine("</table>");
}
}
An unexpected error has occurred - SharePoint Error Page
Lot of course participants of my development courses ask me how to fix the error: An unexpected error has occurred.
If you find nothing in the SharePoint Log you can modify the web.config
<SafeMode MaxControls="200" CallStack="true">
<customErrors mode="Off"/>
You will no longer see the "An unexpected error has occurred" error page and instead you get a lovely ’standard ASP.Net error page’ with the stack trace and everything! It is a best practice to do this on you're development environment. Don't forget to switch it on production!
Styling the Title of WebParts
You can style the text of the header, by styling the .ms-WPTitle.
However be aware that some web part titles contain a hyperlink!! E.g. a hyperlink to the list if using a list WebPart. The little
arrow is also a link, and to style that you can style the <a>-tag
inside the <td>, and then overrule the styling for the header
text. Like this:
/*This styles every link in the header*/
.ms-WPHeader td a{
background-color:#000000;
}
/*This styles every textual link in the header*/
.ms-WPHeader .ms-WPTitle,
.ms-WPHeader .ms-WPTitle a:link,
.ms-WPHeader .ms-WPTitle a:visited{
color:#000000;
}
[/code]
Styling the border around a flyout
By using the CSS-Refence Chart of Heather Solomon (http://www.heathersolomon.com/content/sp07cssreference.htm#TopNav) you can easily style your flyouts. However you can't change the border of the fly-outs. After styling the flyouts you will notice that this border is still blue.
The reason is that the border that comes around the whole flyout area is set on the classname of the .zz1_TopNavigationMenu. Every
flyout menu has it's own classname, but in that classname is a
ID-number. You will never know which numbers will be used, since you do
not know how many menu items there are. For example:
.zz1_TopNavigationMenu_8 {Default.aspx (line 28)
background-color:#F2F3F4;
border:1px solid #A7B4CE;
}
[/code]
But
when you look closer, you see that beside this classname, every flyout
area has the same classname, that is zz1_TopNavigationMenu_0. So,
styling the
border of the flyout menu, will be done by changing the
border of this classname. Like this:
[code:html]
div.zz1_TopNavigationMenu_0{
border:1px #000000 solid; /* white border */}
Upgrading an Existing Master Page to the SharePoint Foundation Master Page
"There have been significant changes to the user interface (UI) for Microsoft SharePoint Foundation 2010, including the addition of the Ribbon. By default, the v4.master page includes the Ribbon. Many of the commands previously found in menus and toolbars now exist inside of the Ribbon. As a result, if your existing master page does not contain the Ribbon, many commands will be unavailable. This topic shows you how to add the Ribbon along with any new controls or content placeholders that are required for an existing master page to render correctly in SharePoint Foundation 2010."
http://msdn.microsoft.com/en-us/library/ee539981(office.14).aspx