Monday, November 21, 2011

SharePoint Get list item parent folder

thanks to author @ http://blogs.tamtam.nl/appie/2009/02/23/Getting+ParentFolder+From+A+Custom+List.aspx

we can use the following method to get parent folder of listitem


static SPFolder GetParentFolder(SPListItem itemToFind, SPFolder folder)
{
      SPQuery query = new SPQuery();
      query.Folder = folder;
      SPListItemCollection items = itemToFind.ParentList.GetItems(query);
     
      foreach (SPListItem item in items)
      {
            if (item.ID == itemToFind.ID)
            {
                  return (folder);
            }
            if (item.Folder != null)
            {
                  SPFolder resultFolder = GetParentFolder(itemToFind, item.Folder);
                  if (resultFolder != null)
                  {
                        return (resultFolder);
                  }
            }
      }

      return (null);
}


So adding that function allows you to get a parentfolder with:

SPFolder parentFolder = GetParentFolder(item, null);







Thursday, November 17, 2011

Get only folders from SharePoint list

thanks to author @ http://www.ktskumar.com/blog/2009/07/retrieve-all-folders-from-list/


the trick is FSObjtype=1.
Use this while querying the list

query.Query = “<Where><Eq><FieldRef Name=’FSObjType’/><Value Type=’Lookup’>1</Value></Eq></Where>”


Monday, November 14, 2011

SharePoint 2010 Empty Recycle Bin


Thanks to author @

http://dhireny.blogspot.com/2010/06/empty-all-items-from-sharepoint-recycle.html#!/2010/06/empty-all-items-from-sharepoint-recycle.html

the trick is
goto recylebin page, then paste this in addressbar textbox in browser

javascript:emptyItems();


then press enter, thats it









SharePoint 2010 + webpart page with quick launch

thanks to author @ http://pscave.blogspot.com/2010/10/show-quick-launch-on-sharepoint-2010.html

the steps are

Delete the following from your webpart page

1.
         < asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>

2.
< asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content>

3.
< style type="text/css">
body #s4-leftpanel {
display:none;
}
.s4-ca {
margin-left:0px;
}
</style>