kamagra how much to take

Get A SharePoint Web Based On List Existence

This code sample demonstrates how to get a specific web based on a SharePoint list, returning the specific web. It also includes several layers of exception handling and various properties that can be set.

  1. protected SPWeb ExampleListWeb
  2. {
  3.         get
  4.         {
  5.                 if (this.ExampleListWeb == null)
  6.                 {
  7.                         try
  8.                         {
  9.                                 if (this.ListWebUrl.Trim() != string.Empty)
  10.                                 {
  11.                                         try
  12.                                         {
  13.                                                 SPSite exampleSite = new SPSite(new Uri(this.Page.Request.Url, this.ListWebUrl, true).ToString());
  14.                                                 exampleSite.CatchAccessDeniedException = false;
  15.                                                 this.ExampleListWeb = exampleSite.OpenWeb();
  16.                                         }
  17.                                         catch (Exception exception)
  18.                                         {
  19.                                                 throw (exception);
  20.                                         }
  21.                                 }
  22.                                 if (this.ExampleListWeb == null)
  23.                                 {
  24.                                         this.ExampleListWeb = SPControl.GetContextWeb(this.Context);
  25.                                 }
  26.                                 this.ExampleListWeb.AllowUnsafeUpdates = true;
  27.                                 this.ExampleListWeb.Lists.IncludeRootFolder = true;
  28.                                 this.ExampleListWeb.Lists.ListsForCurrentUser = true;
  29.                         }
  30.                         catch (Exception exception)
  31.                         {
  32.                                 throw(exception);
  33.                         }
  34.                 }
  35.                 return this.ExampleListWeb;
  36.         }
  37. }
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>