Wednesday, 27 October 2010

The URL ... It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web"

Today I got this error and it took me a while before I found the solution.

The error occured when I was trying to upload a Word document to a Document Library. I did not even get the form where I could add the required data. Meanwhile creating a new document was no problem.
The Docuemnt Library was a default library, where I had programmatically added a few columns.

I began to start focusing on these column, and I deleted them one after another an then, BINGO! When I deleted a SPFieldBoolean column, I could suddenly upload documents.
This columns default property was set to "Yes" and this was all wrong.
Even though its a string property it shall be set to either 0 or 1 meaning no and yes.

Lesson learned.

Friday, 3 September 2010

Get Web template and configuration id

Here is an easy way to get the name of the Web Template and the Configuration id from a SPWeb.

string template = web.WebTemplate; // gives you the name of the Web Template
int configuratuionId = web.Configuration; // gives you the configutaion id

Thats all ;-)

Monday, 23 August 2010

Add ListView Web Part to Site Template

My challange was to add a ListView Web Part in my Site Template. The problem was, that the ListView Web Part is not a "normal" Web Part, but a view of the list i want to show.

This means, that you can't add it in the AllUsersWebPart section as you would normally do. Instead you can add it just after that section.

The code looks like this:

1. First I have added a list in the configuration section.

2. Then I reference a module in the module section.

3. At last, I add the view to the module, just like this.

BaseViewID is the index of the view in the list/library.

I hope you can use this example, and it will save you som time!