To get the Share Point list "url" based on list "Guid", here is the code shown below
SPSite Site = SPContext.Current.Site;
SPWeb web = Site.OpenWeb();
Guid listid = new Guid("{xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}");
web.AllowUnsafeUpdates = true;
SPList List = web.Lists[listid];
string url = SPContext.Current.Site.Url + "/" + List.RootFolder.Url;
Response.Write(url);
web.AllUnSafeUpdates = false;
web.Dispose();
Hopes this helps you a lot.
6 comments:
Thanks...
Depending on your needs, you may want to change that to ...Site.ServerRelativeUrl +"/" +...
That avoids having the http://MyServer.mycompany.com at the beginning, which can mess up alternate access mappings and, if you are storing the URL makes it more portable.
if you are on a subsite, it won't work. So it's better to get the SPWeb url instead of the Spsite :)
sharepoint electronic signature
Thanks for the code. I always get needed help from your blog. You have posted so many useful source codes on your blog. Keep sharing, I will visit again.
thanks , it helped me.
Thanks very much
Post a Comment