Yearly Archive » 2010

Accessing parent web list items carefully

I spent quite some time today fixing this problem of accessing a list item in parent web. What I had to do was to access a list item in a parent web, but strangely it kept returning no result, and I made sure the item did exist in the list.

Then I found out it’s due to permission issue. When accessing a parent web’s list items, you have to run your code under elevated privileges mode, otherwise if you debug it you will see that it crashes when trying to access them.

How to select distinct from SPQuery CAML

A handy way to select distinct records from SPListItemCollection set queried from CAML query. This is very useful when we want to select a number of unique records from a data table.

DataTable dtt = myWeb.Lists["LISTNAME"].GetItems(spQuery).GetDataTable();
DataView dtv = new DataView(dtt);
dtt = dtv.ToTable(true, "COLUMNNAME");

Integrating Ajax into Sharepoint 2007

Recently, I had the chance to play around with ajaxifying Sharepoint server. As you would have probably known, Ajax is a great feature in .NET 3.5 but MOSS 2007 was shipped before Ajax was out. So, to use it, we just need some configurations done. There are a lot of articles on the Internet about how to archieve this, but the very best and well explained one can be found at Mike Ammerlaan’s blog: Integrating ASP.NET AJAX with SharePoint.

Read More

List Attachments Open as Read Only

I had the problem of saving files which I uploaded programatically to Sharepoint list item. When I tried to save them, there’s pop up dialog saying the file is in read only mode, even I had all the required permissions. There’s not much info on the net about this, and luckily I found the solution.

Read More

How to duplicate a Sharepoint list item

I was trying to add a duplicate link to the list item menu dropdown context box, so that user can click and duplicate an item. It’s actually quite easy to do that.

First, what we need to do is add the C# code so that when the item is saved, we check if there is a request query string of relevant item ID. If there is, that means this is going to be duplicated. So the logic works as follow:

Read More

How to create your own custom menu/item/actions in Sharepoint?

Often times we have to customise SharePoint’s stock user interface, particularly elements such as edit block, toolbar, menus, etc. It’s possible to have our own custom items in these areas, but first it would be a lot easier to understand their names and locations respectively. These are some of the common locations we will customize:

Read More