SPList has no default URL Property

Hey guys,

if you working with SPList object be aware of this. If you create a List over C# you only submit a name. But if the name of the List is too long then the url will be truncated.

So you need access to a URL Property to get the right reference to the list!

There are several methods:

1. Access Url over RootFolder property

list = elevatedWeb.Lists[listname];

listUrl = list.RootFolder.Url;


2. Access Url over Forms Property

SPList list = elevatedWeb.Lists[listname];

listUrl = list.Forms["PAGETYPE.PAGE_EDITFORM"].ServerRelativeUrl


3. Write Extenstion Methods for SharePoint

Another Method is to extend the SPList object by writing Extensions Methods. This is described here, many thanks to Adam Buenz



Posted Oct 09 2009, 04:20 PM by Nadine Storandt
Filed under: , ,
developers.de is a .Net Community Blog powered by daenet GmbH.