Monday, October 3, 2011

How to get the full URL from SPListItem in SharePoint

 
1.

static string GetItemUrl(SPListItem listItem)
{
return string.Format("{0}{1}?ID={2}", listItem.Web.Site.Url,
listItem.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl,listItem .ID);
}


2.

listItem.Web.Url  + the listItem.URL


3.

foreach (SPListItem listItemin list.Items)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(listItem.Xml);
XmlNamespaceManager nsm = new XmlNamespaceManager(xmlDoc.NameTable);
nsm.AddNamespace("z", "#RowsetSchema");
string fullURL = xmlDoc.SelectSingleNode("z:row", nsm).Attributes["ows_EncodedAbsUrl"].Value;
}
 

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

How to add "Copy to" and "Move to" options to the right-click context menu in Windows:

Method 1: Registry Editor (Manual) Note: Back up your registry first or create a system restore point. Add "Copy to" Option:...