title: Sharepoint - Item added eventhandler properties do not work
body: <p>I've started programming event handlers.
  At first I added some items to lists with hard coded values.
  Everything worked fine, but then I switched to using properties.OpenWeb() and tried to get the URL with <code>web.Url.ToString()</code> - doing this the handlers won't work and do not emit  any error.</p>
  
  <p>Do I have to change any configuration?
  Have you got a way to solve my problem?</p>
  
  <p>By the way if I try to get values, they are all null.</p>
  
  <p>I am using WSS 3.0 and VS 2008, please see my code below, and thanks!</p>
  
  <pre><code>public override void ItemAdded(SPItemEventProperties properties)
      {
          SPSite site = new SPSite("http://air_sim:1431/");
          SPWeb web = site.RootWeb;
          SPList List = web.Lists["Announcements"];
  
          base.ItemAdded(properties);
  
          SPWeb web1 = properties.OpenWeb();
  
          SPListItem newitem = List.Items.Add();
  
          newitem["Title"] = "test";
          newitem["Body"] = web1.Url.ToString();
  
          newitem.Update();
  
      }
  </code></pre>
  
  <p>By the way i found this code on msdn.
  It doesn't work. No error..nothing, and of couse the condition is true.</p>
  
  <pre><code>public override void ItemAdding(SPItemEventProperties properties)
      {
          using(SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))
          { 
              SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;
  
              if (collItems.Count &gt;1)
              {
                  properties.Cancel = true;
                  properties.ErrorMessage = "Adding items to this list is not supported because it already contains " + 
                      collItems.Count.ToString() + " items.";
              }
          }
      }
  </code></pre>