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

🎬 Installing Kali Linux on a Virtual Machine | Step-by-Step Guide 🐧

🎬 In this video, I’ll show you how to install Kali Linux 🐧 inside a Virtual Machine step-by-step! Whether you're a beginner curious...