Company      |       Articles & Research      |      Services      |      Software      |      Contact

Getting Some SharePoint Object URL’s In C#

There have been some questions posted in the SharePoint development newsgroups about how to appropriately get some object URL's in SharePoint.

Here are some examples:

C#:
  1. public string GetListUrl(SPList oList)
  2. {
  3. if (oList.DefaultView == null)
  4. {
  5. return oList.ParentWeb.Url;
  6. }
  7. return (oList.ParentWeb.Url + "/" + oList.DefaultView.Url);
  8. }
  9.  
  10. public string GetWebUrl(SPWeb oWeb)
  11. {
  12. return oWeb.Url;
  13. }
  14.  
  15. private string GetCurRequestUrl()
  16. {
  17. string l_strCurRequest = this.Page.Request.Url.AbsoluteUri;
  18. if (l_strCurRequest.IndexOf("/", 8)>= 0)
  19. {
  20. l_strCurRequest = l_strCurRequest.Substring(0, l_strCurRequest.IndexOf("/", 8));
  21. }
  22. return l_strCurRequest;
  23. }

Pretty simple, but there were some questions about it.

share save 171 16 Getting Some SharePoint Object URLs In C#

Related posts:

  1. Insert Values Into The URL With C#
  2. Get SPList By URL In C#
  3. Get An XSL Filepath For WebParts
  4. Stupid SharePoint Delimiters
  5. Using BaseTemplate and BaseType

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment