Archive for June, 2010
Visual Studio 2010 properties window – commands & descriptions missing
Posted by Jake in Visual Studio on June 23, 2010
In the Visual Studio 2010 Beta, the Properties Window contained a sub-window that enabled the generation of handlers for workflow properties (not just workflow properties, but any item that had an a event property). I found this to be a quick and consistent way to create those event handling stubs. Upon upgrading to the release version of VS2010, I noticed that the command window was missing:
To display the commands, bring up the context menu for the properties window (right click) and check the commands option. The same goes for descriptions.
SharePoint Ribbon customization for a specific content type
Posted by Jake in SharePoint on June 17, 2010
I wanted to utilize the new SharePoint 2010 Ribbon for performing a custom action on items in a custom list. The list contained items that were of a custom content type (lots of custom work going on). With some great posts from Chris O’Brien and MSDN, I found all the XML needed to accomplish the task. I also took advantage of the Custom Tab, Button Groups and Notifications while I was at it.
A couple of things to note when targeting the content type for ribbon customization. The content type that was used for the CustomAction was created through code, so I didn’t have the ID at design time to add to the Ribbon customization. I deployed the content type first, looked up the content type ID (this can be done quickly by viewing the properties of the CT and looking at the ID in the URL). Once I had that ID, I was able to set the CustomAction RegistrationId to the ID and the RegriatrationType to “ContentType.” Also, I only wanted the button to be active when one or more items were selected. I modified the EnabledScript function to make that happen.
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="SharePoint.Ribbon.SohemasTab" Location="CommandUI.Ribbon" RegistrationId="0x0100ECB394A7B088A843A2421FB7663F957602" RegistrationType="ContentType" > <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location="Ribbon.Tabs._children"> <Tab Id="SharePoint.Ribbon.SohemasTab" Title="Sohema Commands" Description="Sohema Workflow Commands" Sequence="501"> <Scaling Id="SharePoint.Ribbon.SohemasTab.Scaling"> <MaxSize Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup.MaxSize" GroupId="SharePoint.Ribbon.SohemasTab.SohemaActionGroup" Size="OneLarge"/> <Scale Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup.Scaling.SohemasTabScaling" GroupId="SharePoint.Ribbon.SohemasTab.SohemaActionGroup" Size="OneLarge" /> </Scaling> <Groups Id="SharePoint.Ribbon.SohemasTab.Groups"> <Group Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup" Description="Contains Sohema Action items" Title="Perform Sohema Actions" Sequence="52" Template="Ribbon.Templates.OneLargeExample"> <Controls Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup.Controls"> <Button Id="Ribbon.Documents.New.SohemaPushToCSVRibbonButton" Alt="Push selected item(s) to CSV" Sequence="95" LabelText="Push Sohema(s) To CSV" Image16by16="/_layouts/images/SubcontractorSohema/ToCSV16x16.png" Image32by32="/_layouts/images/SubcontractorSohema/ToCSV32x32.png" Command="Command.SohemaPushButton" TemplateAlias="PushSohema" /> </Controls> </Group> </Groups> </Tab> </CommandUIDefinition> <CommandUIDefinition Location="Ribbon.Templates._children"> <GroupTemplate Id="Ribbon.Templates.OneLargeExample"> <Layout Title="OneLarge" LayoutTitle="OneLarge"> <Section Alignment="Top" Type="OneRow"> <Row> <ControlRef DisplayMode="Large" TemplateAlias="PushSohema" /> </Row> </Section> </Layout> </GroupTemplate> </CommandUIDefinition> </CommandUIDefinitions> <CommandUIHandlers> <CommandUIHandler Command="Command.SohemaPushButton" CommandAction="javascript: var notificationId = SP.UI.Notify.addNotification('Processing Sohemas');" EnabledScript="javascript:function moreThanOneEnabled() { var items = SP.ListOperation.Selection.getSelectedItems(); var ci = CountDictionary(items); return (ci > 0); } moreThanOneEnabled(); " /> </CommandUIHandlers> </CommandUIExtension> </CustomAction> </Elements>
Installing Visual Studio 2010 on computer with VMWare running
Posted by Jake in Visual Studio, VMWare on June 7, 2010
This was a curious matter. I installed Visual Studio 2010 on a machine that had VMWare Server running. The VS install went through a restart and installed just fine. When I tried to launch VMWare to access a VM through VMWare Web Access, the VMWare configuration site was not running. Turned out that the VMWare Host Agent (VMwareHostd) was not started (even though it was still set to startup Automatically)! I started that service and was able to access the VMWare config web site. This happened on two different dev machines, so some part of the VS install was being stubborn.
Adding a CSS file to a SharePoint 2010 Application page in VS 2010
Posted by Jake in SharePoint, Visual Studio on June 1, 2010
A quick run down on the steps to add a Cascading StyleSheet to a SharePoint Application page in Visual Studio 2010
From the Visual Studio 2010 Solution Explorer, select the project, right click and select the Add option and then the “SharePoint Mapped Folder…”
The “Add SharePoint Mapped Folder” dialog is presented which displays all the folders under {SharePointRoot}:
Select the location that you would like to place your Stylesheet, which in most cases will be: {ProgramFiles}\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES
Once the STYLES folder is added, it may be easier to add a custom folder that will contain your CSS file(s)
Now that the folder structure is complete, you can add a stylesheet to that folder:
Inside your application page, reference the stylesheet within the PlaceHolderAdditionalPageHead ContentPlaceHolder similar to: <link type="text/css" rel="stylesheet" href="/_layouts/1033/styles/Sohema/sohema.css" />
The details of adding the files to the package is nicely handled by Visual Studio and included in the Package xml files:
Deploy your solution and notice the addition of your CSS file under the location that was specified:
Add content to your CSS file and you’re done!