title: Finding SharePoint list item by its display form's URL
body: <p>Sometimes users require to change information in SharePoint list item that is not editable for them, for instance, a field that is hidden in edit form (in my case it was the records number).</p>
  
  <p>I decided to create a small Windows GUI application that the administrator would run on the server and make the requested change. However, the simplest scenario to get an instance of a <code>SPListItem</code> I found was:</p>
  
  <ul>
  <li>the admin enters the URL of the root site</li>
  <li>an <code>SPSite</code> ojbect is created, using the given URL: <code>SPSite oSite=new SPSite(this.txtURL.text);</code></li>
  <li>admin enters the relative URL of the reqired web</li>
  <li>an <code>SPWeb</code> object is created as <code>SPWeb oWeb = oSite.OpenWeb(this.txtWebUrl.text);</code></li>
  <li>a dropdown box is filled with all the list titles from <code>oWeb.Lists</code></li>
  <li>admin chooses a list from the listbox and enters the ID of the requested item;</li>
  <li>the needed <code>SPListItem</code> is found as <code>oWeb.Lists[this.lstAllLists.selectedValue].GetItemById(this.txtItemId.value);</code></li>
  </ul>
  
  <p>This is a very long path and administrators do no like to do the typing, clicking and waiting.<br>
  They would like to copy the URL of the listitem's display form (from the web browser or somebody's email), paste it into the update tool, then just click "Find it!".</p>
  
  <p>I need hints for how this can be done.</p>
  
  <p>I know I could probably parse the URL with a regex, since it's typically in the form of <code>http://server/sites/[somesite]/[someweb/somesubweb]/lists/[somelist]/forms/dispform.aspx?ID=[123]</code>, but variations exist - for instance, <code>http://[server]/[DocumentLibrary]/Forms/RenamedDispForm.aspx?ID=[1234]</code> has quite different structure than the first example.</p>
  
  <p>So, the question is - is there some easy way to find an <code>SPListItem</code> by it's URL? Reconstructing an <code>SPContext</code> from the URL would be great.</p>
  
  <p>EDIT: Just found out that it is possible to construct a valid <code>SPSite</code> object by passing it a much longer URL:</p>
  
  <pre><code>Dim oSite as New SPSite("http://server/sites/site/Lists/test/DispForm.aspx?ID=136")
  </code></pre>