kamagra how much to take

Getting A List By View URL

It is relatively straightforward to retrieve a list name, or even a strongly typed SPList object in a static reusable format. This can be done with the following:

  1. public string GetListNameFromViewUrl(string currentViewUrl)
  2. {
  3. int index = currentViewUrl.IndexOf("?", StringComparison.Ordinal);
  4. if (index != -1)
  5. {
  6. currentViewUrl = currentViewUrl.Substring(0, index);
  7. }
  8. ParentSite.Lists.ListsForCurrentUser = true;
  9. SPList list = null;
  10. foreach (SPList spList in from SPList spList in ParentSite.Lists
  11. where (spList.Views != null) && (spList.Views.Count != 0)
  12. where (from SPView spView in spList.Views
  13. select new StringBuilder(ParentSite.Url).Append("/").Append(spView.Url)).
  14. Any(builder => currentViewUrl.Equals(builder.ToString())) select spList)
  15. {
  16. list = spList;
  17. }
  18. if (list == null)
  19. {
  20. throw new Exception("Not View In Page");
  21. }
  22. return list.Title;
  23. }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>