Friday, December 26, 2008

Predefine styles in HTML editor in MOSS

A quick note about predefining custom styles in a HTML editor:
Standard, the HTML editor detects CSS classes whose names have the prefix .ms-rteCustom. You can easily extend the OOTB styles by adding .ms-rteCustom-XXX to your custom stylesheet. The name "XXX" will then become available in the styles dropdown within the HTML editor.

Another option is to specify a unique CSS class name prefix. This give you the ability to present different custom styles for different HTML editors of the publishing page. To make a unique CSS class, you have to assign a PrefixStyleSheet property to the HTML field control.

Example:
<.PublishingWebControls:RichHtmlField id="Content" FieldName="PublishingPageContent" runat="server" PrefixStyleSheet="myUniqueClass"./>
Afterwards you can define the "myUniqueClassCustom" class in you custom stylesheet.
Warning: you have to append the word "Custom" to the class, otherwise it won't work! In my opinion, MS doesn't explain this very well...

Example:

Syntax = .[PrefixStyleSheetPropertyName]Custom-[TitleAvailableInEditor]

.myUniqueClassCustom-Header1
{
font-weight: bold;
font-size: 16px;
}

Read How to: Customize Styles for more information.

Sunday, December 7, 2008

Bug: Publishing Image aka RichImageField

Problem:
In certain cases the RichImageField renders an HTML encoded image. It just renders image tags but doesn't render the image.

Workaround:
You have to build a webcontrol that inherits from RichImageField and decode the HTML.

Source: Publishing Images are shown in encoded Html/text instead of showing the image - temporary solution

Wednesday, November 26, 2008

Tip! Yet another CAML query tool

CAML (Collaborative Application Markup Language) is an XML based markup language used with the family of Microsoft SharePoint technologies (Windows Sharepoint Services and Office SharePoint Server). Unlike plain XML, CAML contains specific groups of tags to both define and display (render) data. [wikipedia]

With other words CAML defines various aspects in SharePoint like: views, fields, site definitions, ...

With CAML you can also define queries, which is useful to extract some data from SharePoint lists. Now... writing a simple CAML query isn't that difficult. Given the following example:





It can be difficult if you have more conditional clauses:







Now I probably hear you say: "Sven, what are you talking about? I use the CAML query builder from U2U to construct my queries. That's pretty easy!". I know... that tool is really helpful but what if you have to construct your query dynamically? You can build a flexible query class to simplify the process of creating queries, but it's not necessary. Carlos Segura Sanz (MVP) did this already with his "Yet another CAML Query tool (ala SQL).

With that tool you can construct your query ala SQL. Later on, you can transform the SQL syntax to CAML syntax. Example:
using IdeSeg.SharePoint.Caml.ParseQuery;

string query = @" WHERE ContentType='sharepoint'
AND Firstname = 'Sven'
AND Lastname = 'Gillis'
GROUPBY Title DESC
ORDERBY _Author"
;
try
{
string camlQuery = CAMLParser.Query(query);
SPList list = null;
SPQuery query = SPQuery();
query.Query = camlQuery;
SPItemCollection col = list.getitems(query);
}
catch (ParserException ex) {}
Quite easy, isn't it?

Use "=null" as CAML IsNull operator and "<>null" as IsNotNull also you can use dates enclosed into sharp characters #01/01/1990# the sql Like operator is replaced by CAML Contains and the at "@" operator for the CAML BeginsWith. Also support parentheses for operator precedence.

Oh... btw if you download YACAMLQT you can also use a windows application to support your development. It looks something like this:


















I recently used it in a project and it works like a charm!

Resources:

Saturday, November 22, 2008

WCM: Publishing Site Definition

Creating a new publishing website typically begins by creating a new publishing site collection based on your custom publishing site definition. Nevertheless, it is not necessary to create a custom one because you can also start with the OOTB Publishing Portal Site Definition and then remove the parts that are superfluous. It is quite obvious that this method is not ideal. Starting off with the Blank Site Definition and activating the publishing features is a better option because then you have a quite clean environment to start with.

Probably the best option is to create a Publishing Site Definition from scratch. This way, you "almost" have full control of the provisioning process. Below a few examples which elements you can specify:
  • The welcome page url and the appropriate (custom) pagelayout
  • Automatically activate masterpage, styles, ... features
  • Available web templates
  • Automatically activate the ViewFormPagesLockDown feature - A special feature that restrict access for anonymous users to published content only
  • Alternate CSS url
  • And so on...
In one of my next posts I'll show you how to set a welcome page with your own pagelayout with a custom content type (specified in your publishing site definition).

Saturday, November 8, 2008

Off-topic: E.T.A.

Marvin has the most boring job - ever. But all is not as it seems...

Thursday, October 30, 2008

Access denied when crawling MOSS Content

Banging your head against your screen because you get the following error message...?

Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled. (The item was deleted because it was either not found or the crawler was denied access to it.)

Try the following to fix this:

Disable the loopback check

Follow these steps:
1. Click Start, click Run, type regedit, and then click OK.
2. In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
3. Right-click Lsa, point to New, and then click DWORD Value.
4. Type DisableLoopbackCheck, and then press ENTER.
5. Right-click DisableLoopbackCheck, and then click Modify.
6. In the Value data box, type 1, and then click OK.
7. Quit Registry Editor, and then restart your computer.


Source: http://support.microsoft.com/kb/896861

Saturday, October 25, 2008

Being a devigner can be hard...

Being a what? Well... Heather Solomon introduced this term a couple of years ago. I really agree with her that a SharePoint developer actually is a developer and a designer. On the one side this term makes my life a lot easier. Let me give you an example:

A: Hi, it's been a long time I saw you!
A: What are you doing for living?
B: I'm a SharePoint Developer
A: A what?

You can also say you are working with computers, but then most people will associate you with a salesman or a repairer ... like people in my neighbourhood think I'm a specialist in cleaning up some pc's, working with anti-virus software, etc. Looks familiar?

What if we had told A that we are a "devigner"? Do you think they will understand? Hehe... probably not. I think we just have to say "a software engineer" or for some of you "a software architect" or a "IT manager". But then they are probably not aware of that we also design some stuff. I give up :)

On the other side being a devigner is really hard. In that way that we have to deal with .NET (C#/VB), ASP.NET, SharePoint, CSS techniques and so on... We not only have to know when to dispose objects but also that css sprites are much better than separate images. We need so much knowledge that it is very difficult to become an expert in a specific domain. This fact is quite annoying but we all know SharePoint development is a steep learning curve - We have to deal with it ;)

Tuesday, October 7, 2008

How To: Embed PowerPoint slidedeck into SharePoint page

Do the following steps:

- Open a PowerPoint File
- Save As > Other Formats > Save as type Single File Web Page
- Upload the .mht file to a document library
- Add a Page Viewer WebPart to a Page
- Point the Page Viewer WebPart URL to the .mht file of that doc lib

Result:

Sunday, October 5, 2008

Tips to lure End Users to your SharePoint Portal

A lot of companies are already in possession of SharePoint, but I noticed that not every portal is equally popular. There are intranet / extranet solution who are barely used. It's a pity that they not take care of such a powerful product.

Below a few tips to bring life in your SharePoint Portal:
  • Optimize the information architecture of your site.
  • Analyze the needs of the users: It is important to have a general idea of the different types of users who will be accessing the portal.
  • One of the nice things about SharePoint is that it's relatively intuitive; you don't have to do a lot of training. In my opinion, this statement is not completely true. SharePoint is only partly intuitive if you are quite familiar with computers. SharePoint training for End Users is a must - Only then they will see the usefulness of SharePoint.
  • Don't ignore the look & feel. End users like to work in a neat environment.
  • Make your SharePoint implementation more user-friendly.
  • Make use of Web 2.0 elements like videos, wikis, RSS Feeds, weblogs, podcasts, ...
  • Add some cool features like quiz , document rating, polling webpart, ...
  • Make use of My Sites. It's always fun to play "Rate the picture" with some collegues.
  • Make sure the search engine is easy to use (cfr. Google). You can also extend the OOTB search functionality with faceted search, federated search or others.
  • Make use of statistic tools to monitor the usage of the portal (Site Usage Report, CardioLog, ...)

Tuesday, September 30, 2008

Monday, September 8, 2008

Quick Tip: Rename Custom Tab

If you create a site template in the site template gallery, you will notice that SharePoint automatically creates a new tab, named "Custom", in the Site Template List. Have you ever wondered how to rename that display category? Well... here you can find the instructions.

Sunday, September 7, 2008

Off-topic: Nothing is impossible

The best basketball shot ever

Can anyone tell me this is a valid point?

The best bowling shot ever

Wednesday, September 3, 2008

Best Practices Resource Center for SharePoint Server 2007

At SharePoint Server Techcenter you can find best practices for:
  • Operational Excellence
  • Team collaboration sites
  • Publishing portals
  • Search
  • My Sites
  • Development
I know ... I know ... It's a lot of reading material. For those who don't like reading take a look at:

Saturday, August 23, 2008

Reminder: AllowUnsafeUpdates Issues

What is the AllowUnsafeUpdates property?
The Microsoft idea behind introducing the AllowUnsafeUpdates property is to protect you from cross-site scripting attacks.

When to use?
If your application is running in an HTTPContext (for instance an application page, web part, ...) and the request is a GET request, SharePoint will refuse to do any changes. For this reason you will have to set the AllowUnsafeUpdates to true. Note: By default that property is set to false for GET requests.

When not to use?
In a console application, class library, ... where the HTTPContext.Current is null - AllowUnsafeUpdates will be always true. So you don't have to set this property.

What about breaking role definition inheritance?
When any object that implements ISecurable (those are SPWeb, SPList and SPListItem) breaks or reverts their role definition inheritance. This means every time you call SPRoleDefinitionCollection.BreakInheritance(), BreakRoleInheritance(), ResetRoleInheritance() or set the value of HasUniquePerm the AllowUnsafeUpdates property of the parent web will reset to its default value and you may need to set it back to true in order to do further updates to the same objects.

Bad piece of code:

SPList sharedPictures = curWeb.Lists["Shared Pictures"];
sharedPictures.Title = "My Pictures";
curWeb.AllowUnsafeUpdates = true;
//--> no help!
sharedPictures.BreakRoleInheritance(true);
ReducePermissonsOnLibrary(sharedPictures);
//---> crash!

Exception will be probably: Updates are currently disallowed on GET requests. To allow updates on a GET,set the 'AllowUnsafeUpdates' property on SPWeb.

Working piece of code:

SPList sharedPictures = curWeb.Lists["Shared Pictures"];
sharedPictures.Title = "My Pictures";
sharedPictures.BreakRoleInheritance(true);
CurWeb.AllowUnsafeUpdates = true; //BreakRoleInheritance set AllowUnsafeUpdates back to false!
ReducePermissonsOnLibrary(sharedPictures);


Conclusion: Always set AllowUnsafeUpdates back to true after you break inheritance in an environment with HTTPContext.

AllowUnsafeUpdates and Try/Catch
Steven Van de Craen wrote about this issue.

Resources:

What you need to know about AllowUnsafeUpdates (Part 1)
What you need to know about AllowUnsafeUpdates (Part 2)

Friday, August 1, 2008

PointFire 2007 v2: A Quick Review

SharePoint 2007 is a great product, but it also has his shortcomings. It's not that bad that a platform is not completely mature. It would be bad if we aren't aware of his imperfection. Awareness of its shortcomings means progression! That's the reason why we are working on a vista platform now and not using the win 95 anymore.

Variations

Ok, we all have to admit that SharePoint provides a poor multilingual support. SharePoint is "able" to create and deploy websites that are multi-lingual. It has a feature called Variations that can be used to deploy content in one or more languages. Unfortunately they're not good enough...

why?
Dumping MOSS 2007 variations - Part 1
Dumping MOSS 2007 variations - Part 2
Dumping MOSS 2007 variations - Part 3

Are you sure they are not good enough?
5 reasons why you should not use variations (and more solutions to keep using them)


What about language packs?

Language packs enable site owners and site collection administrators to create SharePoint sites and site collections in multiple languages without requiring separate installations of Windows SharePoint Services 3.0. Language packs are typically used in multinational deployments where a single server farm supports people in different locations or in situations where sites and Web pages must be duplicated in one or more languages.

An important thing to note:

You cannot change an existing site, site collection, or Web page from one language to another by applying different language-specific site templates; once you choose a language-specific site template for a site or a site collection, the site or site collection will always display content in the language of the original site template.


PointFire 2007

IceFire -Canadian company- developed an add-in called PointFire 2007 (why not calling it FirePoint? Sounds much better :)) that provides multilingual user interface and content management for SharePoint 2007 (MOSS & WSS).

I've been testing the product with some colleagues and I have to admit that this is probably the best multilingual solution available. It's easy to install, easy to use and really really powerful! In 1 click you can easily translate your site settings, userprofile information details, built-in sharepoint menus, ...

PointFire also has a Multilingual Translations List to enable users to add, edit and override any interface translations. It's like a dictionary in which you can store terms in different languages.

Another fancy thing is that you are able to hide/show certain content depending on the current language.

It provides more features than described above ... for a complete list take a look at MOSS is now multilingual and also at the official site for new added features. Here's a video to see a few features in action. Here's a product overview (.ptt).

Oh... I forgot to mention one thing. PointFire has also his shortcomings. But it's not that bad - remember? ;)

Wednesday, July 23, 2008

Lockdown Mode Feature

Rich Finn recently wrote a blogpost about the the ViewFormPages-LockDown feature. In this he mentioned that a lot of public-facing internet sites running on SharePoint haven't activated that particular feature. The funny thing is that Rich refers to the result-set from Live Search, which is returning 29,200 results! For more information read Rich's post and also the following article.

Monday, July 21, 2008

Word Document Preview

I occupied myself with building a quite simple Word document preview functionality in SharePoint. In some situations it might be handy to take a peek in the content of a Word document (read: DOCX document) before opening, editing, ... In most cases, styles and images used in the document doesn't matter - we just want to recognize our previously written document by reading some text content.

Solution

To accomplish this functionality I made use of Eugene Pankov's DocxToText class available at codeproject (modified it a bit) and used the open-source ZIP library SharpZipLib. Maybe I'll take the time to rewrite this functionality with the System.IO.Packaging namespace in the near future.

Attention

I know, the solution isn't 100% complete and not tested extensively. The errorhandling isn't optimal and the functionality is limited yet (sort documents by name, paging is enabled, display x content blocks) ... but feel free to modify to your needs. Download the solution.

Screenshots

Custom Action on every document library

CustomAction

Custom application page

wordprev1

Content appears when you hover over the document name (standard 5 alineas)

wordprev2

When 5 alineas isn't enough ... change the textbox value

wordprev3

Monday, June 30, 2008

Uploading Error: Unable to complete this operation

Situation: You try to upload a document to a document library and get the following error:

Unable to complete this operation. Please contact your administrator.

Solution: Take a look at your SQL Server database storage capacity. There's a possible chance that there's no space available.

How to: Add value to Lookup field

1. Check whether the value is available in the Lookup List









2. Add the existing value to the lookup field


Wednesday, June 18, 2008

SharePoint Quote

While I was reading a blogpost I saw a comment from someone who wrote the following:

This is great! This is another reason why SharePoint is the center of the IT universe.

Lol, imo this quote is the center of the Quote universe.

Sunday, June 15, 2008

End-to-End Content Deployment Walkthrough

There's finally a whitepaper available about the content deployment feature in Microsoft Office SharePoint Server 2007.

The content deployment feature offers the ability to move content from one farm to another either manually or on a predetermined schedule.

Download: End-to-End Content Deployment Walkthrough

Tuesday, June 10, 2008

Wednesday, May 21, 2008

Silverlight charts with Visifire

I recently started playing around with Silverlight in SharePoint. I took a look at the Silverlight BluePrints to start with... Oh man, what a hell to get a sample working! A lot of people were complaining about a blank webpart... and of course I had the same problem. Recompiling the Silverlight project in VS 2008 helped for me.

After trying a few examples from the BluePrints I took a look at Visifire...

Visifire is a set of open source data visualization components - powered by Microsoft® Silverlight. With Visifire you can create and embed visually stunning animated Silverlight Charts within minutes.


I examined the Asp.net example and gave it a try to build a chart based on some list data.


A sample SharePoint list with some data (Year and Profit)



Based on the data from the SharePoint list I created a Silverlight Column Chart. Looking good isn't?







You can also choose other visually stunning animated charts.
eg. line charts, donuts, columns, ...






To bring this to a next level... I'm trying to embed this in a SharePoint webpart. I was thinking about the SilverLightPart "wrapper" webpart from the BluePrints to do this job. Normally, this webpart is able to wrap a .XAP file to embed your silverlight applications. But first, I'll have to create a new Silverlight application to create a .XAP file (The above example is just an aspx page) . I am working on this...

It all looks well, but still in its infancy! :)

Tuesday, May 20, 2008

Concentra.be in the air!

Recently, a new public facing SharePoint website went online.

Concentra is a multimedia media company with a decentralised structure, which gives each medium or market the full chances that they need in order to grow.

There are seven activity clusters within Concentra: Newspapers, Free Press, Industry and Services, Audio-Visual, Books and Magazines, Classifieds and Digital Media.

Part of the advertising sales activities for the various activities fall under Concentra Media Regie, the group’s internal sales division.















I'm quite happy with the result... especially for my first WCM project.
Just take a look at concentra.be...

PS. I recommend watching the site in Dutch (not all pages are included in other languages)

Thursday, May 15, 2008

Bulk editable workflow tasks

Have you ever heard about bulk workflow tasks? Hmm... neither had I! In one of our analyses I read there was no out of the box solution to edit workflow tasks at the same time. I did some research and found that in some cases you have the opportunity to mark for instance 5 workflow tasks of a certain type as "complete" for a given workflow association.

It is a pity that there only one predifined workflow (disposition workflow) in Office SharePoint 2007 that supports that option. However, there is a way to accomplish this behavior. First, you have to build a "custom" workflow template definition that define task types as bulk editable. Then, you also have to build an infoPath edit form with different views (one for individual task editing and also one for bulk editing).

For more info, take a look at:
Bulk editing workflow tasks in Office SharePoint Services 2007
How to: define a worklow task as bulk editable

A pile of workflow resources

It gives me the shudders when I hear about the word "workflow". As everybody will admit, workflow development is a heavy matter. Tom Nys, on the other hand, isn't scared of them... Next week I'll attend his presentation about workflow foundation at BIWUG.

Some useful workflow resources:
Recource 1
Recource 2

Thursday, April 24, 2008

A way to style elements on a page

There are several ways to add styles to elements on a page...
  • You can set a reference to a css file (from the style library) directly in the masterpage / page layout

  • You can specify a CSS file via the UI. Navigate to Site Settings > Site Master Page Settings -> Alternate CSS URL section

  • You don't have to use CSS files... you can also do it inline.

  • Another option is by using a Content Editor WebPart. In my option it is quick and dirty, but in some cases it might be useful.

How to style with a Content Editor WebPart?

  1. Set a CssClass for your control you want to style (or just a div with a class attribute)
    eg. myPanel.CssClass = "myPanel"

  2. Drag a Content Editor WebPart on the page

  3. Open the source editor and set the Css styles


When you are back in displayMode you will see that we have an ugly line (with default a webpart title). To hide this you can modify the webpart properties:

  • (appearance section) set the width attribute to "1px".
  • (appearance section) set Chrome Type to "None"
  • (appearance section) set Title to ""

Result: Our Content Editor WebPart is completely hidden and we have styled our page ;)

SharePoint Bug? SPListItem.Url

If you request the Url property of an SPListItem you'll retrieve an unexisting Url. Check out SPListItem.URL Funky Return Fiesta for further information. This property seems to work only for docitems. Weird!

Wednesday, April 23, 2008

How To: Make a nice looking contactform WebPart with AJAX

On my previous project I had to make some contactforms, to allow anonymous users to send an e-mail. I decided to make it as a webpart. I know, you can also do it with an application page (?), user controls with smartpart, etc... But a webpart has the advantage of properties and portability. Please, correct me if i'm wrong. I would really appreciate comments - other suggestions for making a form?

I made the contactform webpart without AJAX & Styling. Just a simple form with some simple validation handling. Everytime I build a customisation for a client, I always wondering if there wasn't a better (more beautiful, faster, other algorithm, etc) approach... In this case I started thinking about a nice looking contactform with AJAX validation and some nifty corners.

I gave it a try and my form looks like this:



After you have submitted the form:







How I did it...
  • I downloaded & installed the ASP.NET 2.0 AJAX Extensions 1.0
  • I modified my web.config
  • I placed a ASP.NET AJAX Script Manager into the masterpage
  • I downloaded the ASP.NET AJAX Control Toolkit

After these steps I created a webpart with the following code:















Attention:
On Mike Ammerlaan's blog you'll read the following:


ASP.NET AJAX infrastructure is not compatible with output caching features. This output caching infrastructure is a featured component of managed content pages such as those supported by web content management features in Microsoft Office SharePoint Server. For this reason, many scenarios which involve output cached features may not be able to take advantage of components like UpdatePanel. However, you will be able to successfully use other ASP.NET AJAX features, such as the JavaScript library, combined with your output cached pages.


In my next post I'll show you a way to style the elements inside the webpart...

Thursday, April 3, 2008

Tip! SharePoint Search in combination with anonymous users

Have you already noticed that every time an unauthenticated user tries to search, a user prompt shows up? Well this is due to the fact that the OSSSearchResults.aspx has an inheritance reference to "Microsoft.SharePoint.WebControls.LayoutsPageBase". This inheritance isn't necessary to work properly. So... What you can do is just removing the whole line in the page directive "Inhertis=...." and save it. Don't forget to make a copy of the file!

Note - On MSDN you can read:

In general, use LayoutsPageBase as a base class for pages that should only be accessible to authenticated users with certain rights. For pages to which even
unauthenticated users should have access, use the parent class UnsecuredLayoutsPageBase.


I have tried to switch to this base class, but it didn't work for me. Anyone who did it?

Wednesday, March 26, 2008

Unable to add selected Webpart(s)...

I got the error above in the following situation:

I developed a custom masterpage and on that masterpage I added a Label control. Afterwards, the label is filled up with some list data (in my case: information from a page library) . Maybe I could work with a webpart, but I don't think it's evident to put a webpart on a masterpage.

Everything worked fine until I saw that I coudn't add any webpart anymore. Believe me, it was hard to find out the cause of the problem. After excluding many possibilities I discovered that it was something in my masterpage. And guess what ... my innocent label was the cause of the whole thing!

Solution:
Because of the fact that my code works fine in DisplayMode of a page, I surrounded my code with the following condition:

if (SPContext.Current.FormContext.FormMode.Equals(SPControlMode.Display))
{
//Populate the "innocent" label
}

The condition will check whether you are in DisplayMode are not... If so... populate the label.

The mysterious 0x80020009 Error

This time we have to deal with a tough boy! The error has probably something to do with disposing of objects...

I wrote a contact webpart, who has several custom properties to set the labels and some other info (SMTP Server name, Success Message, etc.). When I added my new webpart to the page and set the properties - everything works fine. But... when I modified the text of a label, I got the following error message:


Cannot save the property settings for this Web Part. Exception occurred.
(Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))

The first thing you do when you see an error like that is to verify the ULS Logs and take a look at the eventviewer. The eventviewer indicated no problem.

The ULS Log gave me the following message:


Trying to store a checked out item (/page.aspx) in the object cache. This may be because the checked out user is accessing the page, or it could be that the SharePoint system account has the item checked out. To improve performance, you should set the portalsuperuseraccount property on the web application. See the documentation for more information.


So I:
--- removed the webpart
--- added him back to the page
--- modified the custom properties ... works ok (surprisingly!)
--- a couple of hours later... modified it ... didn't work anymore!

I haven't found a solution for it...
Hezser talked about disposing SP objects correctly - but in my webpart I don't use SPWeb, SPSite, etc... . I'll update this post when I get more information.

Worth to mention: The same webpart and thus the same code works fine on my developing machine. Spooky!

Hezser blog (Dispose SP objects correctly)
Paul Gavin's SharePoint Space (no solution yet)

Update: I discovered that my custom webpart is not the only victim. Other webparts are poisoned as well.

Solution: My "innocent" label was the cause of the problem. See my next post about "unable to add selected webpart".

Friday, March 21, 2008

The ErrorLady loves me

Ok... another post about a great error. This time it's the lovely Page Layout Error:

Only Content controls are allowed directly in a content page that contains Content controls


It's unnecessary to write down my whole story because Rich Finn already made an excellent blogpost about it.

Let me summarize Rich Finns story in a oneliner: Make sure that the ASP Content tag starts with a capitalized letter <.asp:Content>

Code Block are not allowed in this file

If you want to add some inline code in a masterpage or pagelayout file... you probably get the following error message:

An error occurred during the processing of blabla.aspx. Code blocks are not allowed in this file.

To get this working you need to modify the web.config of your web application. For instance, if you want to allow server side script on pages from the masterpage & pagelayout gallery you have to modify the PageParserPaths into:

<.pageparserpaths>
<.pageparserpath virtualpath="/_catalogs/masterpage/*" compilationmode="Always" allowserversidescript="true" includesubfolders="true".>
<./pageparserpaths>

Tuesday, March 11, 2008

Solution Deployment Failed

When you got the following error during solution deployment (WSPBuilder):

Failed to extract the cab file in the solution

just verify if you have used special characters like é,ä,ö,å, etc. in the name of the files you want to provision. For example: If you build a pagelayout and you give him the name "ManagementComité.aspx" ... the solution deployment will fail. Be aware of this issue in the future.

Monday, March 10, 2008

Display choices using checkboxes (allow multiple selections)

In this post I'll show you how to make a multichoice site column. First I was looking in the SDK for an appropriate value for the attribute "Format" of a choice field.

The MOSS SDK says the following about the Format attribute:

For Choice fields, this attribute can be set to Dropdown (default), which provides editing options through a drop-down selection, or to RadioButtons, which provides options through a group of radio buttons.

If you have already created a choice site column with the UI in SharePoint you will have noticed that you have several display modes of a choice field:

Display choices using:
  • Drop-Down Menu
  • Radio Buttons
  • Checkboxes (allow multiple selections)

So I thought the display modes were related to the Format Attribute of the Choice field (Isn't that logic?). I was wrong! After a while I found another (the correct) type to realize a multichoice checkbox thing. The type is "MultiChoice":


Specifies a Choice field that implements check boxes and allows the user to select multiple values.


An example of how to make a multichoice field with a feature...

<.Field ID="{EB21EEF7-9B67-4eb8-8CC9-15F76264121F}" Name="Vacature Product" Group="Vacature Page Layout Site Columns" DisplayName="Product" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields" StaticName="Vacature Product" Type="MultiChoice" Required="TRUE" FillInChoice="TRUE">
<.CHOICES.>
<.CHOICE>Marketing & Product Management<./CHOICE.>
<.CHOICE>Sales & Services<./CHOICE.>
<.CHOICE>Productie<./CHOICE.>
<.CHOICE>Redactie<./CHOICE.>
<.CHOICE>ICT & Design<./CHOICE.>
<.CHOICE>Human Resources<./CHOICE.>
<.CHOICE>Financieel & Business analyse<./CHOICE.>
<./CHOICES.>
<./Field.>

After the site column creation, you can use this fieldtype in a pagelayout with the CheckBoxChoiceField class.

Example:
<.SharePointWebControls:CheckBoxChoiceField FieldName="Product" runat="server" ID="CheckBoxChoiceField1"/.>

Wednesday, February 27, 2008

Display Custom Field in a Content Query Web Part

Today I struggled with a problem when trying to display a custom field into my CQWP. I tried to display a custom field whose internal field consist of two parts. eg. News Date.

When I filled in the internal field name this way:
<.property name="CommonViewFields" type="string".>News Date,Text;<./property.>" the field didn't render.

Solution
<.property name="CommonViewFields" type="string".>News_x0020_Date,Text;<./property.>"

The characters _x0020_ represent the blank space.

Retrieve List Guids, Internal Field Names & ContentTypeIDs

When you are in want of some Guids, Internal Fieldnames or ContenttypeIDs during the development... you don't have to look that far. I just realized that the info is available in the URL.

So when you need a List Guid, just navigate to the list settings page and copy the Guid after the "List=" string. Be aware of that the GUID is URL encoded. For that reason you have to decode the Guid or just remove the special characters and add braces.

For a ContenttypeID, navigate to the contenttype in the site contenttype gallery and copy the ID after the "ctype=" string out of the URL.

For an internal Fieldname, navigate to the site column page for a particular column and copy the fieldname after the "field=" string out of the URL.

Sunday, February 3, 2008

Automatically activate a Site/Web Scoped Feature

I'm wondering if there is a way to automatically activate Site or Web scoped features after the feature installation. I did some research and found a XML attibute "ActivateOnDefault", which you can place in the feature definition file (feature.xml).

I placed the attribute into the feature.xml to force the feature to activate himself after installing, with no results...

Reason:
The ActivateOnDefault attribute does not apply to site collection (Site) or Web site (Web) scoped Features.

In general, Farm-scoped Features become activated during installation, and when a new Web application is created, all installed Web application-scoped Features in it become activated.

So I think the only way to accomplish this is to write some code within the "FeatureInstalled" method of the FeatureEventHandler: Activate features through code.

Problem with deleting a solution

For once I got an error when trying to remove an existing SharePoint Solution (.wsp) from the SharePoint Server.

The solution cannot be removed when a job is scheduled or running

Also when you go to the Central Administration > Operations > Solution Management, you will notice that an error shows up in the list of solutions.

Off course there is a way to fix this. Alex Thissens wrote a nice blogpost of this issue. Maybe there are other ways to fix this, but Alex' way worked for me.

Thursday, January 24, 2008

Performance issues with Virtual PC on laptops

If your Virtual PC runs in slowmotion try the following:

a. Stop running Virtual PC
b. Open notepad
c. Open %appdata%\Microsoft\Virtual PC\options.xml (appdata is a hidden directory)
d. Add or edit <.virtual_machines.> section of the file and add this key:
<.enable_idle_thread type="boolean">true

eg. It should be on the same level as the node
(just put it after the last <./virtual_network.> node)


<.virtual_machines.>
<.enable_idle_thread type="boolean">true<./enable_idle_thread>
<./virtual_machines>


f. Save the file and exit notepad
g. Start Virtual PC
h. Don't forget to remove the dots in the XML above

Source: Virtual PC Guy's WebLog

Tuesday, January 15, 2008

MCTS 70-536 Practice Test humor



Just look at the picture and you will know what I mean. PS. The yellow boxes are the "correct" ones...

Tuesday, January 8, 2008

Timer Job Schedule Classes

It was hard to find a list of all the schedule classes and examples of how to use them. I found it on a French site. You can always use Babelfish to translate the page;)

Wednesday, January 2, 2008

Business Data Catalog Links

~Best wishes for the new year~

For those who are new to the BDC check out the channel 9 introduction video.

The BDC is all about the application definition file (XML File) that describe the metadata model for the backend system that you are connecting to. You can either create it manually or semi-automatically with tools.

I recommend to start learning the basic elements of an application definition before using tools. The reason for that is that you sometimes need to modify a definition after you have generated one. Especially the free MS BDC Tool (available in the MOSS 2007 SDK) has his shortcomings... but its a great tool to support your application definition development.

One of the best resources about the BDC on the net to create definition files manually: Blah!Blah!Blog!!

And some recent posts about the Business Data Catalog Editor:
-Using business data catalog Editor
-Working with business data column