Showing posts from 2010

Hooking into ASP Client Side Validation

The Problem: The ASP Validators are hard to style. The Validators only render a <span> with the error information. What if you want to display the complete div around the control to be red when an error occures? This is likely not possible with the standard asp validators.

What you can do is o write a decorator in javascript. The function which displays the errormessages is the "ValidatorUpdateDisplay" method.

1: /** 2: * @requires JQuery 1.4.x 3: */ 4: var Biggy = {}; 5: 6: Biggy.Validator = { 7: /** 8: * Decorator for the ms validator update function 9: * 10: * @param {orig_fn} Function 11: * The function to decorate 12: * @return Function 13: * The decorated fucntion 14: */ 15: UpdateDisplayDecorator : function(orig_fn) { 16: return function(){ 17: var originalfunc = orig_fn.apply(this, arguments); 18: Biggy.Validator.UpdateParentDisplay( arguments[0] ); 19: return originalfunc; 20: }; 21…

SharePoint 2010 Timer Job UpdateProgress

SharePoint 2010 has updated some of its timer job features (see Now SPJobDefinition offers an UpdateProgress Method, to show the status of the timer job in a status bar.

To check the status of a timer job go to "Central Administration > Monitoring > Check Job Status".

The following code snipplet  is an example of how you could use this method. The job reads a rss feed and uploads some pdf files into a document library. The progress bar is updated by each uploaded file. The snipplet is not complete, because of copyright. I commented out some regions but you can see how you could use the updateprogress function.

public class PressListTimerJob : SPJobDefinition
/// <summary>
/// We must persist the to have in the execute function
/// </summary>
private String mRootSiteUrl = String.Empty;        

public PressListTimerJob() : base() { }

public PressListTimerJob(str…

Play a video from a asset library in SharePoint with the built-in Silverlight Media Player

The Problem:
You want to place a link into your SharePoint site which opens the Silverlight player in a lightbox and plays a video from a asset library.


1) Place the link within an other HTML element like a div, li or span and give this element an id. The link can be somewhere in this container, also in a deeper level

- the link to the video must be serverrelative
- the link can have a title. This can be used as Video title

<div id="mediaplayer">
   <a href="/site/listname/myvideo.wmv">Video</a>

2.) Place a script tag for the mediaplayer library and a custom script tag for our custom js. You must place it after or in the onload event, because when you use getElementById the element must exist in the DOM.

<div id="mediaplayer">    <a href="/site/listname/myvideo.wmv">Open Video</a>  ..  .. </div> <script type="text/javascript" src="/_layouts/mediaplayer.js">&…

Setting the default page layout in onet.xml (SharePoint 2010)

In SharePoint 2010 you have the option to choose a default page layout when you create a page.

When you create a new page, a dialog pops up where you enter the name of the site.

You can configure your onet.xml and define the default page by the defaultpagelayout property in the publishing feature.

Or you can set it programmatically as described in SharePoint Blues.

There are also several other properties offered by the Publishing feature you can set:

ChromeMasterUrlWelcomePageUrlPagesListUrlAvailableWebTemplatesAvailablePageLayoutsNewPageUrlTokenAlternateCssUrlSimplePublishingVersioningOnPages / Documents / ImagesEnableModerationOnPages / Documents / ImagesEnableApprovalWorkflowOnPages / Documents / ImagesRequireCheckoutOnPages / Documents / ImagesEnableSchedulingOnPages /Documents / ImagesAllowSpacesInNewPageName
Each property needs a different value. You can find a good listing of the properties and values to use on blog post of Carsten Keutmann.

If SimplePublishing is set to false,…

ContentTypeBinding Error - Object reference not set to an instance of an object

An error occurred binding content type '0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900...' to list '/ct2/Pages' on web 'http://pilatus/ct2'.  Exception 'Object reference not set to an instance of an object.'.

This exception occures when you try to bind an empty or non-existent content type to a list. An empty content type is a content type with no fields.

Example of an empty content type.
<ContentType ID="0x010100C568DB52D9D0A14.."
  Name="Basic Page"
  Description="Basic Page">
<!-- here must be some fields -->
    <DocumentTemplate TargetName="/_layouts/CreatePage.aspx" />  </ContentType>

MatchPoint Condition - Show only data from last months

If you have a MatchPoint Composite oder DataGrid WebPart and you want to show data from a list which is from current month, from the last months or coming months you can use following condition(s). The field you check should be DateTime field.

The condition checks if the content of the Date field is lower than the 1st of the current month. If you want the last day of the month, you can use AddMonth(1).AddDays(-1)

How to hide the SharePoint Ribbon in Non-Edit Mode

If you’ve ever developed a page for SharePoint 2007 you certainly used the EditModePanel control to control content visibility. This control now has changed in SP 2010 and ignores the Page Editmode. But there is a possibility to do this with no custom code.

 Locate the position of the class "s4-ribbonrow" and add a display style. (Or overwrite the class in your css). This will hide the panel in DisplayMode.
<div class="s4-pr s4-ribbonrowhidetitle" id="s4-ribbonrow" style="display: none;">

Add following code after the ribbon div. This will show the ribbon in EditMode.
<publishingwebcontrols:authoringcontainer displayaudience="AuthorsOnly" runat="server"><publishingwebcontrols:editmodepanel pagedisplaymode="Edit" runat="server"><script type="text/javascript">  document.getElementById("s4-ribbonrow").style.display = "block";</script></publishingwebco…

Check if a SharePoint page is in edit mode

Everyone who ever created a MasterPage for SharePoint certainly used the EditModePanel control, to show some controls only in "edit" mode. I use the EditModePanel control to load some javascript and css when the page is in edit mode. This is useful when I want to correct webparts, which are to small a.s.o.

<PublishingWebControls:EditModePanel runat="server" id="EditModePanelJSNone">
<script type="text/javascript">
/* <![CDATA[ */
   Editmode = true;
/* ]]> */

Now I realized that this control doesn't function when it is used with personalized pages. A personalized page saves a snapshot of the page either in edit or display mode.

So I had to check per javascript if a page is in edit mode. Since each of my pages have a webpart zone and a webpartzone has a edit banner in edit mode, I check if this banner exists, by searching after a image that only exits in webpart edit ban…

JediScript - Objektorientiertes JavaScript

Ich arbeite momentan an einem Whitepaper, in der ich meine Erkenntnisse mit objektorientierten JavaScript zusammenfasse. Es ist eine Zusammenfassung von den grundlegenden Prinzipien bis hinzu Konzepten in produktiven Umgebungen.

Heute stelle ich eine Vorschau von 20 Seiten zur Verfügung. In meiner freien zeit versuche ich das Dokument zu vervollständigen.

Inhalt in diesen 20 Seiten sind:

EinleitungWieso OOTypen in JSMichale JSON - Who is itUnterschied defined & nullFunky functionsDie magischen KlammernDo you know what this is?deleteprivate und public PropertiesNamespacesDie Var-polizeiClosures
Download JediScript (pdf - 757kb)

Include Javascript and CSS Compression in Visual Studio

For a frontend developer it is a must to compress his javascript and css files, before deploying a website to a productive environment. In this post I'll demonstrate how you can automate this process in Visual Studio.

First of all download the YUI Compressor for .Net. (3.5)

Extract the zip file and copy the to files into a folder in your visual studio solution. I have a folder called "Libraries" for third part dll files.

Create a file "MSBuildCompress.xml" in a folder you want. I put this file in my "_Tools" folder.

Put the following xml in your newly created xml file.

<?xml version="1.0" encoding="utf-8"?>
<!-- Author Baris Bikmaz -->
<!-- MSBUILD Task to compress css and js files with the yui compressor -->
<Project xmlns="">