The Black Knight Sings

Songs about SharePoint and other adventures by Per Jakobsen


Date: # Sunday, November 16, 2008

Title: WCMexport version 1.0


When you're branding a site using SharePoint 2007 Web Content Management, you really want to spend your time changing Master Pages and Page Layouts. But you often find that you spend a lot of your time editing your Feature.xml and different Elements.xml files especially if you have a lot of different Page Layouts with web parts for different parts of the site.
WCMexport is a small utility which can help you if you don't like doing all the editing of the xml-files from scratch.
With WCMexport you can use SharePoint Designer or what other tool you want to create the Master Pages, Page Layouts and Style Library Files on a development site.



Sunday, November 16, 2008 1:52:46 PM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Date: # Thursday, August 21, 2008

Title: Turn Default Upload Overwrite Off in WSS 3.0


By default the Overwrite checkbox in Upload.aspx is checked in WSS 3.0 and MOSS 2007, but sometimes you may want to change this default.

MOSS junkie has a post on how to change that default.
But his solution has the downside of having to modify one of the standard application pages which is unsupported and may be overwritten by a upgrade

So how do we change the default without modifying upload.aspx?

Once again the <delegate> controls in the default masterpage can help us.
This time it's the AdditionalPageHead delegate we can use. This delegate allows you to add any number of usercontrols to the page header of every page in sites where your feature is activated.
So we add a feature with the following elements.xml file:



Thursday, August 21, 2008 11:52:41 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Date: # Friday, August 15, 2008

Title: Remove the Search Box from SharePoint Sites


Sometimes you don't want your users to be able to search on your SharePoint site.
Part one of this is then to remove your site from the content source in SSP, but you probably also want to remove the Search box from every page in your site.

Fortunately SharePoint makes this very easy

The different version of SharePoint has different requirements for the Search box and the way these different serach boxes are implemented are using the Delegate feature of WSS
Delegates are controls in a masterpage/page whose content is determined by which Features are activated.
Each Delegate has an ID (SmallSearchInutBox for the Search box) and each Feature can vote for it's content by specifying an Control element.
For Delegates where AllowMultipleControls are false (like SmallSearchInputBox) the Control with the lowest sequence wins (25 is the lowest sequence used by OOB Feature)
So to disable the Search box all you have to do is implement a Feature which has a Control element with sequence below 25 pointing to an empty UserControls.
If you don't want to develop this yourselves you can just download my implementation which makes a Feature with WebApplication scope.
The source files are here and a precooked solution file is here



Friday, August 15, 2008 8:38:30 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Date: # Wednesday, July 16, 2008

Title: Remove Login box when anonymous users download office document from SharePoint Site


When developing Extranet/Internet site in SharePoint you often want to allow anonymous access and this works fairly well.
But there is one are where the out of the box experience fails regarding anonymous access and that is when you allow the users to download Microsoft Office documents. In that case IE/Office pops up a couple of Login dialogs, if the user cancels out of these the document opens as expected, but you really don't want the user to have to cancel a couple of dialogs to open your documents

The problem is that office tries to be intelligent and issues a Microsoft Office Protocol Discovery request to see how much the user is allowed to do, but SharePoint responds with access denied until the users logs in.

The solution I've found is to implement a HttpModule which rejects the Microsoft Office Protocol Discovery request if the user isn't logged in and this gets rid of the Login boxes
The essential code is fairly simple:



Wednesday, July 16, 2008 5:33:49 PM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Date: # Monday, July 14, 2008

Title: FeatureReceiver To Cleanup WebPart Files


Many web-part developers are surprised to see that their web-parts are listed as available even though they have deactivated the feature which contains them

And the users are equally surprised when they then try to add the web-part only to see it fail because the code (and safe-control entry) has been removed.

The problem comes from the fact that deactivating a Feature doesn't remove files provisioned using Module and File entries



Monday, July 14, 2008 6:02:34 PM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Title: Features inside a Solution isn't deactivated when the Solution is retracted


Features and Solutions are two of the best features in WSS 3.0 (except for their names, which makes it very hard to write and speak about them):
* Features because they make it very easy (at least compared to WSS 2.0) to add functionality to a SharePoint site
* Solutions because they take care of much of the hassle about getting the features out on all the servers in the farm

One of the great strengths of Features is the ability to have code executed when the Feature is activated and again when it's deactivated. This is very handy for doing any kind of setup and teardown. Especially as there is quiet a few of the declarative features of Features which only works on the first activation (e.g. existing files/content types isn't updated) and some of the declarative features which is left when deactivating. In the last category is the one that surprises web-part developers most. They've learnt to install .webpart files into the WebPart gallery using Module/File elements and are quiet surprised when they later deactivate their feature and finds that the WebParts is still listed as being available because the .webpart files are left in the WebPart gallery, but when users then try to add the webpart it fails because the code has been removed. See this post on how to fix that.

The possibility to execute code on install/uninstall of a feature isn't normally that interesting until you notice the bug in the Feature/Solution cooperation:
Features inside a Solution isn't deactivated when the Solution is retracted
Instead the solution just uninstalls the feature while it's still activated, this means that the e.g web parts is removed but that the FeatureDeactivating code isn't run with all kinds of nasty error as a result.



Monday, July 14, 2008 5:40:41 PM (Romance Standard Time, UTC+01:00)  #    Comments [7]

Date: # Wednesday, July 09, 2008

Title: Registered for PDC2008


Even though it seems that there isn't going to be any SharePoint stuff a PDC this year, I still regard it as the Microsoft event of the year, it's our chance to see the direction in which Microsoft is heading:
* Oslo
* Windows 7
* Silverlight
* SQL server 2008
* F#
* ...

I'm going to be there (just finished the registration) and am looking forward to meet a lot of fellow developers.

Join the show and lets have some SharePoint discussions in the Open Space



Wednesday, July 09, 2008 8:35:10 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Date: # Thursday, July 03, 2008

Title: Implementing a simple Cascading Dropdown in a usercontrol


A user wanted some guidance on how to implement a cascading dropdown in SharePoint. The following will show a simple example of how to implement that as a user control which has properties for selecting a list, a choice field in that list for the first dropdown and a field for which all appropriate values are shown in the second dropdown



Thursday, July 03, 2008 7:29:00 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Date: # Friday, June 27, 2008

Title: How to use a publishing page as display form


A client wanted to place a SharePoint calendar on a publishing page and have it configured such that when you clicked an event the full details showed up at the top of the page, and searching for calendar items should also put you at this page.

Sounds easy just put the calendar view on the page and set the calendars display form to be that page. But setting the display form to be the publishing page puts the ID of the calendar item in the URL of the publishing page which then confuses SharePoint as it thinks it has to lookup that id in the Pages list.

The solution is to introduce a page as display form which the redirects back but with the ID of the calendar item as a querystring parameter with another name than ID.



Friday, June 27, 2008 11:17:59 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Title: Look up instance of potentially recurring calendar event


In my last post I described how to redirect to a publishing page in order to use it as display form for a calendar.

It caused the problem of having to look up the right instance of the calendar event (in case of recurrence) ourselves. If we just implement an ordinary display form SPContext does the lookup for us.

I poked around in the SDK to find a method which could look up an item from a list based on the RecurrenceID, but without any luck. I knew SPContext did this so I fired up Reflector to see how SPContext did this and found GetInstanceItem which did what I wanted, but tightly coupled to the SPContext's current List and then it was also a private method.

Despite the DRY principle I had to reimplement the same function.



Friday, June 27, 2008 9:39:29 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. And all information or programs are without warranty. Use at your own risk


© Copyright 2009 Send mail to the author(s) Per Jakobsen Feed your aggregator (RSS 2.0)