Archive for September, 2007

Posted by Adam Buenz

I wish I would have known about this trick a long time ago. Jim Sally whom I work with demonstrated to me a really neat commenting trick that I did not know about, that really helps when you are mocking out objects particularly. When you have some arbitrary class file, like this jawdropper
Select [...]

Posted by Adam Buenz

There have been some questions posted in the SharePoint development newsgroups about how to appropriately get some object URL's in SharePoint.
Here are some examples:
Select For Unformatted Code
C#:

public string GetListUrl(SPList oList)

{

if (oList.DefaultView == null)

{

return oList.ParentWeb.Url;

}

return (oList.ParentWeb.Url + "/" + oList.DefaultView.Url);

}

 

public string GetWebUrl(SPWeb oWeb)

{

return oWeb.Url;

}

 

private string GetCurRequestUrl()

{

string l_strCurRequest = this.Page.Request.Url.AbsoluteUri;

if (l_strCurRequest.IndexOf("/", 8)>= 0)

{

l_strCurRequest = l_strCurRequest.Substring(0, l_strCurRequest.IndexOf("/", 8));

}

return [...]

Posted by Adam Buenz

Answering another development question that was posted in the newsgroups, someone wanted to know assuming that they were aware of the path of an SPFolder object (a subfolder that existed in a SharePoint document library), how to return the GUID of the SharePoint document library that was housing the relevant SPFolder object. This is accomplished [...]

Posted by Adam Buenz

There was a question posted in the development newsgroups about how to structure a different SPList return method then the orthodox SPWeb.GetList method out of the Microsoft.SharePoint namespace. Here is one that I use, which has some slight enhancements.
Select For Unformatted Code
C#:

public SPList ReturnListByUrl(string strPath)

{

if (strPath.ToLower().StartsWith("http"))

{

strPath = strPath.Substring(m_oWeb.Url.Length + 1);

if (strPath.ToLower().StartsWith("lists"))

{

strPath = strPath.Substring(6);

}

}

if (strPath.IndexOf("/")> 0)

{

strPath [...]