Thursday, January 10, 2013

How to get Absolute URL of List using SharePoint object model?

In this post we will discuss how to get absoulte URL of a list using SharePoint object model.

You can also check my previous posts on Get 14 hive file path by using SharePoint 2010 object model [Solution here], Add safe controls programmatically in SharePoint 2010 [Solution here] and Add items to SharePoint list using PowerShell [Solution here].

We can use the SPUtility class to retrieve the absolute or full URL of the SharePoint list.
using (SPSite siteCollection = new SPSite("http://bsahoo3:2500/sites/TestSiteCollection/"))
            {
                using (SPWeb web = siteCollection.OpenWeb())
                {
SPList list = Web.Lists["Employees"];

string listUrl = SPUtility.GetFullUrl(site, list.DefaultDisplayFormUrl);
 }
}
This will return the DisplayForm Url like below

http://bsahoo3:2500/sites/Lists/Employees/DispFormASPX

You can see some SharePoint 2013 articles.

4 comments:

  1. packers and movers in india@
    https://quicksoluction.com
    packers and movers in delhi@
    http://quicksoluction.com/packers-and-movers-in-delhi.html
    packers and movers in mumbai@
    http://quicksoluction.com/packers-and-movers-in-mumbai.html
    packers and movers in pune@
    http://quicksoluction.com/packers-and-movers-in-pune.html
    packers amd movers in gurgaon@
    http://quicksoluction.com/packers-and-movers-in-gurgaon.html

    ReplyDelete
  2. An excellent information provided thanks for all the information i must say great efforts made by you. thanks a lot for all the information you provided.
    Packers And Movers Bangalore

    ReplyDelete
  3. Packers and movers in indore@
    http://www.transmoving.in/packers-movers-indore.html
    Packers and movers in jaipur@
    http://www.transmoving.in/packers-movers-jaipur.html
    Packers and movers in thane@
    http://www.transmoving.in/packers-movers-thane.html
    Packers and movers in varanasi@
    http://www.transmoving.in/packers-movers-varanasi.html
    Packers and movers in surat@
    http://www.transmoving.in/packers-movers-surat.html
    Packers and movers in lucknow@
    http://www.transmoving.in/packers-movers-lucknow.html

    ReplyDelete