<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kit Menke&#039;s Blog &#187; SharePoint 2007</title>
	<atom:link href="http://kitmenke.com/blog/category/sharepoint07/feed/" rel="self" type="application/rss+xml" />
	<link>http://kitmenke.com/blog</link>
	<description>Experiences with SharePoint, web development, and programming</description>
	<lastBuildDate>Wed, 01 Feb 2012 17:28:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Workspace permissions and Project.QueuePublish</title>
		<link>http://kitmenke.com/blog/2011/11/17/workspace-permissions-and-project-queuepublish/</link>
		<comments>http://kitmenke.com/blog/2011/11/17/workspace-permissions-and-project-queuepublish/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 22:04:59 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Project Server]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=402</guid>
		<description><![CDATA[Imagine you work for a large company that uses Microsoft Project Server. Since you have many employees, having MSP sync individual permissions for every user to every site is simply not scalable. Instead, you&#8217;d like to use some Active Directory groups that are already set up to manage permissions in the workspace. So you disable [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you work for a large company that uses Microsoft Project Server. Since you have many employees, having MSP sync individual permissions for every user to every site is simply not scalable. Instead, you&#8217;d like to use some Active Directory groups that are already set up to manage permissions in the workspace.</p>
<p>So you disable the workspace permissions sync in PWA:</p>
<ol>
<li>Navigate to PWA</li>
<li>Click Server Settings</li>
<li>Click Project Workspace Provisioning Settings</li>
<li>Validate that the &#8220;Workspace Permissions&#8221; checkbox is unchecked</li>
</ol>
<p style="text-align: center;"><a href="http://kitmenke.com/blog/wp-content/uploads/2011/11/msp-workspace-permissions.png"><img class="size-medium wp-image-404 aligncenter" title="MSP Workspace Permissions" src="http://kitmenke.com/blog/wp-content/uploads/2011/11/msp-workspace-permissions-300x67.png" alt="Microsoft Project Server Workspace Permissions" width="300" height="67" /></a></p>
<p>Then, perhaps you write some code that is wrapped up in a nice SharePoint feature to manage setting up the permissions yourself. Everything works great&#8230;.</p>
<p>&#8230; until you start getting reports that some user&#8217;s permissions aren&#8217;t quite right for some project sites.</p>
<p><span id="more-402"></span></p>
<p>You investigate and find a whole bunch of permissions with Project Server roles:</p>
<ul>
<li>Readers (Microsoft Office Project Server)</li>
<li>Team members (Microsoft Office Project Server)</li>
<li>Project Managers (Microsoft Office Project Server)</li>
<li>Web Administrators (Microsoft Office Project Server)</li>
</ul>
<p>More investigation into the PWA Manage Queue Jobs page, you also see &#8220;WSS Workspace Create&#8221; coming up in the queue.</p>
<p>Wait&#8230; I thought we disabled the permissions sync! Why is it still syncing from MSP?</p>
<p>If you&#8217;ve read this far, I&#8217;m guessing you&#8217;ve also written some custom code for Project Server using the Project Server Interface (PSI) (or you&#8217;re using the ProjTool app to publish the project). Which means, you&#8217;re probably using the <a href="http://msdn.microsoft.com/en-us/library/gg177147.aspx" target="_blank">Project.QueuePublish</a> method and you probably have something like this:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> WSS_URL <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// do not create a project site</span><br />
<span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">bool</span> FULL_PUBLISH <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
jobId <span style="color: #008000;">=</span> Guid<span style="color: #008000;">.</span><span style="color: #0000FF;">NewGuid</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
projectSvc<span style="color: #008000;">.</span><span style="color: #0000FF;">QueuePublish</span><span style="color: #008000;">&#40;</span>jobId, projectId, FULL_PUBLISH, WSS_URL<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>When fullPublish is true, <strong><span style="color: #ff0000;"><span style="color: #000000;">it will also sync permissions from MSP</span> even when it is disabled in workspace provisioning settings</span></strong>. If the project site exists already, it will also sync permissions to that existing site.</p>
<p>The workaround is simple.. set fullPublish to false:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> WSS_URL <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// do not create a project site</span><br />
<span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">bool</span> FULL_PUBLISH <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// if true, causes the permissions sync</span><br />
jobId <span style="color: #008000;">=</span> Guid<span style="color: #008000;">.</span><span style="color: #0000FF;">NewGuid</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
projectSvc<span style="color: #008000;">.</span><span style="color: #0000FF;">QueuePublish</span><span style="color: #008000;">&#40;</span>jobId, projectId, FULL_PUBLISH, WSS_URL<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>TODO: What is the difference when fullPublish is true vs false?</p>
<p>P.S. If you are managing your own security, I recommend using the SharePoint API to create workspaces instead of PSI methods. After you create the workspace from your project template, you can just link it up to the Project in MSP:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">_project<span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateProjectWorkspaceAddress</span><span style="color: #008000;">&#40;</span>projectUid, newWebName, wssWebAppUid<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=402&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2011/11/17/workspace-permissions-and-project-queuepublish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web services, XmlNode, and XPATH</title>
		<link>http://kitmenke.com/blog/2011/07/26/web-services-xpath/</link>
		<comments>http://kitmenke.com/blog/2011/07/26/web-services-xpath/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 15:33:18 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=382</guid>
		<description><![CDATA[I was writing a little web services app to help delete individual permissions from a site and thought about trying XPATH on the result to get what I needed. I had some trouble so thought I&#8217;d put together a small example for later reference. The XML from the Permissions GetPermissionCollection web service looks something like: [...]]]></description>
			<content:encoded><![CDATA[<p>I was writing a little web services app to help delete individual permissions from a site and thought about trying XPATH on the result to get what I needed. I had some trouble so thought I&#8217;d put together a small example for later reference.</p>
<p><span id="more-382"></span></p>
<p>The XML from the Permissions <a href="http://msdn.microsoft.com/en-us/library/dd586703%28v=office.11%29.aspx">GetPermissionCollection</a> web service looks something like:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;GetPermissionCollection</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/sharepoint/soap/directory/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Permissions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Permission</span> <span style="color: #000066;">MemberID</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">Mask</span>=<span style="color: #ff0000;">&quot;-1&quot;</span> <span style="color: #000066;">MemberIsUser</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">MemberGlobal</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">GroupName</span>=<span style="color: #ff0000;">&quot;IT Projects Owners&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Permission</span> <span style="color: #000066;">MemberID</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">Mask</span>=<span style="color: #ff0000;">&quot;138612833&quot;</span> <span style="color: #000066;">MemberIsUser</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">MemberGlobal</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">GroupName</span>=<span style="color: #ff0000;">&quot;IT Projects Visitors&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Permission</span> <span style="color: #000066;">MemberID</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">Mask</span>=<span style="color: #ff0000;">&quot;1011028719&quot;</span> <span style="color: #000066;">MemberIsUser</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">MemberGlobal</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">GroupName</span>=<span style="color: #ff0000;">&quot;IT Projects Members&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Permission</span> <span style="color: #000066;">MemberID</span>=<span style="color: #ff0000;">&quot;1073741823&quot;</span> <span style="color: #000066;">Mask</span>=<span style="color: #ff0000;">&quot;-1&quot;</span> <span style="color: #000066;">MemberIsUser</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">MemberGlobal</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">UserLogin</span>=<span style="color: #ff0000;">&quot;SHAREPOINT\system&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Permissions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/GetPermissionCollection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>The main heartache I had when trying to use XPATH was that the XML uses a <strong>default namespace</strong> (the xmlns=&#8221;" part). In order to select the Permission nodes, you need to use a XmlNamespaceManager:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Permissions webSvc <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Permissions<span style="color: #008000;">&#40;</span>site<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
XmlNode result <span style="color: #008000;">=</span> webSvc<span style="color: #008000;">.</span><span style="color: #0000FF;">GetPermissionCollection</span><span style="color: #008000;">&#40;</span>site<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, <span style="color: #666666;">&quot;Web&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
XmlNamespaceManager nsmgr <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> XmlNamespaceManager<span style="color: #008000;">&#40;</span>result<span style="color: #008000;">.</span><span style="color: #0000FF;">OwnerDocument</span><span style="color: #008000;">.</span><span style="color: #0000FF;">NameTable</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
nsmgr<span style="color: #008000;">.</span><span style="color: #0000FF;">AddNamespace</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;sp&quot;</span>, <span style="color: #666666;">&quot;http://schemas.microsoft.com/sharepoint/soap/directory/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #6666cc; font-weight: bold;">string</span> xpathQuery <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;sp:Permissions/sp:Permission&quot;</span><span style="color: #008000;">;</span><br />
XmlNodeList nodeList <span style="color: #008000;">=</span> result<span style="color: #008000;">.</span><span style="color: #0000FF;">SelectNodes</span><span style="color: #008000;">&#40;</span>xpathQuery, nsmgr<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>Here is <a href="http://stackoverflow.com/questions/4245678/get-sharepoint-list-visible-columns-names-through-web-service-using-c/4249198#4249198">another example on Stackoverflow</a>.</p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=382&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2011/07/26/web-services-xpath/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Customizing EditForm.aspx in a Publishing site</title>
		<link>http://kitmenke.com/blog/2010/12/11/customizing-editform-aspx-in-a-publishing-site/</link>
		<comments>http://kitmenke.com/blog/2010/12/11/customizing-editform-aspx-in-a-publishing-site/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 04:56:56 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[MOSS2007]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=318</guid>
		<description><![CDATA[After recently doing a lot of work heavily customizing NewForm.aspx and EditForm.aspx for a SharePoint list, I ran into a major issue after I moved my list into a publishing site. The issue appeared when I added a webpart onto my EditForm. As soon as another webpart was added, the entire page switched into some sort [...]]]></description>
			<content:encoded><![CDATA[<p>After recently doing a lot of work heavily customizing NewForm.aspx and EditForm.aspx for a SharePoint list, I ran into a major issue after I moved my list into a publishing site. The issue appeared when I added a webpart onto my EditForm.</p>
<p><span id="more-318"></span></p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/normal-view.png"><img class="alignnone size-medium wp-image-321" title="normal view" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/normal-view-300x105.png" alt="" width="300" height="105" /></a><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/normal-view.png"></a></p>
<p>As soon as another webpart was added, the entire page switched into some sort of weird publishing mode.</p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/publishing-view.png"><img class="alignnone size-medium wp-image-323" title="publishing view" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/publishing-view-300x129.png" alt="" width="300" height="129" /></a><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/publishing-view.png"></a></p>
<p>This new mode has a couple of changes to the form:</p>
<ol>
<li>A publishing toolbar now appears at the top</li>
<li>Every field in the List View Web Part has an additional &#8220;form&#8221; label</li>
<li>Additional JavaScript is added to the page that prompts the user to save whenever an attempts to navigate somewhere differently: To save your changes before continuing, click &#8220;OK&#8221;. To continue without saving changes, click &#8220;Cancel&#8221;.</li>
</ol>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/publishing-view-red.png"><img class="alignnone size-medium wp-image-322" title="publishing view red" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/publishing-view-red-300x129.png" alt="" width="300" height="129" /></a></p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/javascript-dialog.png"><img title="javascript dialog" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/javascript-dialog-300x66.png" alt="" width="300" height="66" /></a></p>
<p>In my case, this new mode definitely would not work for what I was trying to do. The labels increase the size of the form dramatically, the publishing toolbar makes it seem as if you are editing the page rather than a list item, and this new mode does NOT appear on NewForm.aspx which means the forms are dramatically inconsistent.</p>
<p>After googling, I found a couple of people who have had <a href="http://social.msdn.microsoft.com/Forums/en/sharepointcustomization/thread/e10ad027-c28a-43ab-8b48-bb02dc3ca782">similar</a> <a href="http://social.msdn.microsoft.com/Forums/en-CA/sharepointcustomization/thread/f00d37d3-2254-44fa-8f4d-ae7683c645cf">issues</a>. The root cause seems to be the Office SharePoint Server Publishing site feature. Since disabling the feature on the site was not an option, I had to find another way. JavaScript and CSS was a viable option (since I&#8217;m customizing the form using these anyway) but I felt like I needed a more bullet proof method.</p>
<p>My method involves using SharePoint Designer to customize EditForm.aspx. (<strong><span style="color: #ff6600;">Updated January 13th, 2011</span> after ADE&#8217;s comment below. Thanks a lot!) </strong></p>
<p><strong>Step 1: </strong>Create a new custom EditForm.aspx by right clicking on EditForm.aspx, click &#8220;New From Existing Page&#8221;</p>
<p><strong> </strong></p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/new-from-existing-page.png"><img class="alignnone size-medium wp-image-330" title="new from existing page" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/new-from-existing-page-300x196.png" alt="" width="300" height="196" /></a><strong> </strong></p>
<p><strong>Step 2:</strong> Add the SPNavigation line in right before PlaceHolder Main:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;asp:Content</span> <span style="color: #000066;">ContentPlaceHolderId</span>=<span style="color: #ff0000;">&quot;PlaceHolderLeftNavBar&quot;</span> <span style="color: #000066;">runat</span>=<span style="color: #ff0000;">&quot;server&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="display:block;background-color:#ffff66"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;asp:Content</span> <span style="color: #000066;">ContentPlaceHolderId</span>=<span style="color: #ff0000;">&quot;SPNavigation&quot;</span> <span style="color: #000066;">runat</span>=<span style="color: #ff0000;">&quot;server&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br /></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;asp:Content</span> <span style="color: #000066;">ContentPlaceHolderId</span>=<span style="color: #ff0000;">&quot;PlaceHolderMain&quot;</span> <span style="color: #000066;">runat</span>=<span style="color: #ff0000;">&quot;server&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div></div>
<p><strong>Step 3: </strong>Save your new CustomEdit.aspx into the same directory as EditForm.aspx</p>
<p><strong>Step 4: </strong>Verify your list now is associated with your new CustomEdit.aspx by right clicking on the list in SharePoint Designer and clicking &#8220;Properties&#8221;.<br />
<a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/list-properties.png"><img class="alignnone size-medium wp-image-329" title="list properties" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/list-properties-300x188.png" alt="" width="300" height="188" /></a><br />
Your new edit form should be listed under the Supporting Files tab for Edit item form:<br />
<a href="http://kitmenke.com/blog/wp-content/uploads/2010/12/list-properties-box.png"><img class="alignnone size-medium wp-image-331" title="list properties box" src="http://kitmenke.com/blog/wp-content/uploads/2010/12/list-properties-box-300x291.png" alt="" width="300" height="291" /></a></p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=318&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/12/11/customizing-editform-aspx-in-a-publishing-site/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Wrap ListViewWebPart Column Headers</title>
		<link>http://kitmenke.com/blog/2010/07/08/wrap-listviewwebpart-colum-headers/</link>
		<comments>http://kitmenke.com/blog/2010/07/08/wrap-listviewwebpart-colum-headers/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 18:55:58 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[MOSS2007]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=258</guid>
		<description><![CDATA[I recently got asked if it was possible wrap the column headers in a list view web part. The user had a WebPart with quite a few columns with long names and was trying to prevent the page from scrolling left to right. What we needed to do was wrap the column header so that [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got asked if it was possible wrap the column headers in a list view web part. The user had a WebPart with quite a few columns with long names and was trying to prevent the page from scrolling left to right.<br />
<span id="more-258"></span></p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/07/2010-07-08-13-48-02.png"><img class="alignnone size-full wp-image-259" title="Column Header (nowrap)" src="http://kitmenke.com/blog/wp-content/uploads/2010/07/2010-07-08-13-48-02.png" alt="Column Header (nowrap)" width="600" height="165" /></a></p>
<p>What we needed to do was wrap the column header so that it fit more to the data in the grid.</p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/07/2010-07-08-13-47-27.png"><img class="alignnone size-full wp-image-260" title="Column Header (wrapped)" src="http://kitmenke.com/blog/wp-content/uploads/2010/07/2010-07-08-13-47-27.png" alt="Column Header (wrapped)" width="600" height="165" /></a></p>
<p>The solution is relatively simple to implement; all you need is a Content Editor Webpart at the bottom of the page somewhere with the following JavaScript in it:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span> <br />
<span style="color: #003366; font-weight: bold;">function</span> WrapColumnHeaderText<span style="color: #009900;">&#40;</span>columnName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> tables <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;table&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> tables.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// find the table that is for the column we're looking for</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> attrItem <span style="color: #339933;">=</span> tables<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;displayname&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">!=</span> attrItem <span style="color: #339933;">&amp;&amp;</span> attrItem.<span style="color: #660066;">nodeValue</span> <span style="color: #339933;">===</span> columnName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> cells <span style="color: #339933;">=</span> tables<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;td&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> c <span style="color: #339933;">&lt;</span> cells.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> c<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">!=</span> cells<span style="color: #009900;">&#91;</span>c<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;nowrap&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cells<span style="color: #009900;">&#91;</span>c<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">removeNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;nowrap&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// after removing nowrap, IE won't actually wrap the content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// until it &quot;changes&quot;.. so we touch it to force it to wrap</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cells<span style="color: #009900;">&#91;</span>c<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> cells<span style="color: #009900;">&#91;</span>c<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>ex.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> WrapColumnHeaders<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// TODO: repeat the line below to wrap more columns</span><br />
&nbsp; &nbsp; WrapColumnHeaderText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Company Product Code&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
_spBodyOnLoadFunctionNames.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;WrapColumnHeaders&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></div></div>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=258&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/07/08/wrap-listviewwebpart-colum-headers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple AJAX App using SharePoint Web Services</title>
		<link>http://kitmenke.com/blog/2010/03/14/a-simple-ajax-app-using-sharepoint-web-services/</link>
		<comments>http://kitmenke.com/blog/2010/03/14/a-simple-ajax-app-using-sharepoint-web-services/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 00:08:18 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=224</guid>
		<description><![CDATA[In this era of Web 2.0 web applications, I think it was only a matter of time before I needed to investigate how I could apply AJAX to SharePoint. With a little JavaScript and SharePoint&#8217;s web services, you can build fancy apps that can easily be dropped into a document library. And after reading Glen [...]]]></description>
			<content:encoded><![CDATA[<p>In this era of Web 2.0 web applications, I think it was only a matter of time before I needed to investigate how I could apply AJAX to SharePoint. With a little JavaScript and SharePoint&#8217;s web services, you can build fancy apps that can easily be dropped into a document library. And after reading <a href="http://blog.glenc.net/2007/04/20/calling-sharepoint-web-services-from-javascript/">Glen Cooper&#8217;s blog post</a> on the subject, I figured it was something definitely worth investigating.</p>
<p>I also took this opportunity to improve a process I have to do all the time: what are the internal column names in a list? To get the list information, I built a simple AJAX app that consumes the Lists.asmx web service. Please keep in mind that this code will have be uploaded into  SharePoint in order to work (a document library will work) and will not run from your desktop.</p>
<p><span id="more-224"></span></p>
<h2>Step 0: HTML for user input and displaying results</h2>
<p>Since I will be calling the GetList method on Lists.asmx, I will need two parameters from the user: Site URL and List Name. Site URL gives the web service context to a particular web and List Name should be a list within that web. I also specify a DIV which is where I will display the list&#8217;s information.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;controls&quot;</span>&gt;</span><br />
   <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/fieldset.html"><span style="color: #000000; font-weight: bold;">fieldset</span></a>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/legend.html"><span style="color: #000000; font-weight: bold;">legend</span></a>&gt;</span>List Information<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/legend.html"><span style="color: #000000; font-weight: bold;">legend</span></a>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtSiteURL&quot;</span>&gt;</span>Site URL:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtSiteURL&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:400px&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://server/sites/SiteCollection/SubSite&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>Example: http://server/sites/SiteCollection/SubSite<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtListName&quot;</span>&gt;</span>List Name:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtListName&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Images&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>Example: Images<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btnExecute&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Get Columns&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/fieldset.html"><span style="color: #000000; font-weight: bold;">fieldset</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;result&quot;</span>&gt;</span><br />
   (results)<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></div>
<p>Now that we have our HTML form, we can work on the JavaScript code.</p>
<h2>Step 1: Building a SOAP Message</h2>
<p>To communicate with the web service, we need to use SOAP. Luckily, Glen has already created a very handy class for taking care of these operations. It is also reusable so it will come in handy for other web service calls. I tweaked his code a little bit and then put it into SoapUtils.js (also, please note this code depends on <a href="http://www.prototypejs.org/">Prototype.JS</a>):</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
SoapUtils.js<br />
Author: Glen Cooper<br />
http://blog.glenc.net/2007/04/20/calling-sharepoint-web-services-from-javascript/<br />
*/</span><br />
<span style="color: #003366; font-weight: bold;">var</span> Soap <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
   createEnvelope<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>action<span style="color: #339933;">,</span> ns<span style="color: #339933;">,</span> parameters<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
      <span style="color: #003366; font-weight: bold;">var</span> soap <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;'</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;soap:Envelope xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;'</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'  &lt;soap:Body&gt;'</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'    &lt;'</span> <span style="color: #339933;">+</span> action <span style="color: #339933;">+</span> <span style="color: #3366CC;">' xmlns=&quot;'</span> <span style="color: #339933;">+</span> ns <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;'</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> Soap.__parseParameters<span style="color: #009900;">&#40;</span>parameters<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'    &lt;/'</span> <span style="color: #339933;">+</span> action <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&gt;'</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'  &lt;/soap:Body&gt;'</span><span style="color: #339933;">;</span><br />
      soap <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;/soap:Envelope&gt;'</span><span style="color: #339933;">;</span><br />
      <span style="color: #000066; font-weight: bold;">return</span> soap<span style="color: #339933;">;</span><br />
   <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
<br />
   __parseParameters<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>parameters<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
      <span style="color: #003366; font-weight: bold;">var</span> params <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> parameters <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
         <span style="color: #006600; font-style: italic;">// check if we were provided an array or an object</span><br />
         <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> parameters.<span style="color: #660066;">push</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> length <span style="color: #339933;">=</span> parameters.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
               params <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span> <span style="color: #339933;">+</span> parameters<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&gt;&quot;</span> <span style="color: #339933;">+</span> parameters<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/&quot;</span> <span style="color: #339933;">+</span> parameters<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span><br />
            <span style="color: #009900;">&#125;</span><br />
         <span style="color: #009900;">&#125;</span><br />
         <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
            $H<span style="color: #009900;">&#40;</span>parameters<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>pair<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
               params <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span> <span style="color: #339933;">+</span> pair.<span style="color: #660066;">key</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&gt;&quot;</span> <span style="color: #339933;">+</span> pair.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/&quot;</span> <span style="color: #339933;">+</span> pair.<span style="color: #660066;">key</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span><br />
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
         <span style="color: #009900;">&#125;</span><br />
      <span style="color: #009900;">&#125;</span><br />
      <span style="color: #000066; font-weight: bold;">return</span> params<span style="color: #339933;">;</span><br />
   <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>This utility class handles a lot of the grunt work for creating the SOAP message. It makes it pretty easy to grab the input, build the message, and then send it to the server. Next, I need to give it the specifics it needs to build the actual message. This is all contained inside my Execute function:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> Execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Executing...&quot;</span><br />
<br />
   <span style="color: #003366; font-weight: bold;">var</span> txtSiteUrl <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'txtSiteURL'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> txtListName <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'txtListName'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
   <span style="color: #006600; font-style: italic;">// build parameter object</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> parameters <span style="color: #339933;">=</span><br />
   <span style="color: #009900;">&#123;</span><br />
      listName<span style="color: #339933;">:</span> txtListName<br />
   <span style="color: #009900;">&#125;</span><br />
<br />
   <span style="color: #006600; font-style: italic;">// create soap envelope</span><br />
   <span style="color: #006600; font-style: italic;">// can find the action and namespace from the WSDL page</span><br />
   <span style="color: #006600; font-style: italic;">// ex: http://servername/_vti_bin/Lists.asmx?op=GetList</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> soap <span style="color: #339933;">=</span> Soap.<span style="color: #660066;">createEnvelope</span><span style="color: #009900;">&#40;</span><br />
     <span style="color: #3366CC;">&quot;GetList&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// action</span><br />
     <span style="color: #3366CC;">&quot;http://schemas.microsoft.com/sharepoint/soap/&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// namespace</span><br />
     parameters<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>txtSiteUrl.<span style="color: #660066;">endsWith</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
      txtSiteUrl <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'/'</span><span style="color: #339933;">;</span><br />
   <span style="color: #009900;">&#125;</span><br />
   txtSiteUrl <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'_vti_bin/Lists.asmx'</span><span style="color: #339933;">;</span><br />
<br />
   <span style="color: #006600; font-style: italic;">// call web service</span><br />
   <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Request</span><span style="color: #009900;">&#40;</span><br />
     txtSiteUrl<span style="color: #339933;">,</span><br />
     <span style="color: #009900;">&#123;</span><br />
       method<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;post&quot;</span><span style="color: #339933;">,</span><br />
       contentType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;text/xml&quot;</span><span style="color: #339933;">,</span><br />
       postBody<span style="color: #339933;">:</span> soap<span style="color: #339933;">,</span><br />
       onSuccess<span style="color: #339933;">:</span> ajaxSuccess<span style="color: #339933;">,</span><br />
       onFailure<span style="color: #339933;">:</span> ajaxError<br />
     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>The Execute method is then bound to the &#8220;Get Columns&#8221; button on page load:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
   Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'btnExecute'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span>Execute<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h2>Step 2: Parsing the Web Service&#8217;s XML response</h2>
<p>At this point, we are ready to handle the response from the web service. Unfortunately, parsing XML using JavaScript was not exactly the easiest experience. I haven&#8217;t found an easy way to do it, so if you have any ideas, please let me know in the comments.</p>
<p>In any case, if an error occurs, I simply want to print the error message:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> ajaxError<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
   Element.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>bottom<span style="color: #339933;">:</span><span style="color: #3366CC;">'&lt;span style=&quot;color:red&quot;&gt;'</span> <span style="color: #339933;">+</span> result.<span style="color: #660066;">responseText</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>A success message is a lot more complicated since we want to extract information out of the returned XML. In fact, if you look at the entire response from the webservice after calling GetList, the returned result for a simple Images library is something like 1100 lines of XML. The majority of this is taken up by the full description of each column in the list. There is a LOT of junk that we are simply going to be skipping over. For sanity sake, I&#8217;m not going to post the entire response, but useful snippets of interest.</p>
<p>Overall, the response will look something like:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;GetListResponse</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/sharepoint/soap/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;GetListResult<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;List</span> <span style="color: #000066;">RequireCheckout</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">EnableMinorVersion</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">ShowUser</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">Ordered</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">MultipleDataList</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">Hidden</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">EnableVersioning</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">EnableModeration</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">EnableAttachments</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">AllowMultiResponses</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">AllowDeletion</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">HasUniqueScopes</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">WorkFlowId</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">MajorWithMinorVersionsLimit</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">MajorVersionLimit</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ScopeId</span>=<span style="color: #ff0000;">&quot;317f19e2-4ba8-4ecc-82f3-9d846a270840&quot;</span> <span style="color: #000066;">SendToLocation</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">WebId</span>=<span style="color: #ff0000;">&quot;0bb1435c-d56a-4f6a-93a7-77ad6990a48c&quot;</span> <span style="color: #000066;">WebFullUrl</span>=<span style="color: #ff0000;">&quot;/sites/SiteCollection/SubSite1/SubSite2&quot;</span> <span style="color: #000066;">EmailAlias</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">EmailInsertsFolder</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">EventSinkData</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">EventSinkClass</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">EventSinkAssembly</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">Author</span>=<span style="color: #ff0000;">&quot;630&quot;</span> <span style="color: #000066;">WriteSecurity</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">ReadSecurity</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">RootFolder</span>=<span style="color: #ff0000;">&quot;/sites/SiteCollection/SubSite1/SubSite2/Images1&quot;</span> <span style="color: #000066;">AnonymousPermMask</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ItemCount</span>=<span style="color: #ff0000;">&quot;6&quot;</span> <span style="color: #000066;">Flags</span>=<span style="color: #ff0000;">&quot;4232&quot;</span> <span style="color: #000066;">WebImageHeight</span>=<span style="color: #ff0000;">&quot;480&quot;</span> <span style="color: #000066;">WebImageWidth</span>=<span style="color: #ff0000;">&quot;640&quot;</span> <span style="color: #000066;">ThumbnailSize</span>=<span style="color: #ff0000;">&quot;160&quot;</span> <span style="color: #000066;">Direction</span>=<span style="color: #ff0000;">&quot;none&quot;</span> <span style="color: #000066;">Version</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">LastDeleted</span>=<span style="color: #ff0000;">&quot;20081001 01:58:47&quot;</span> <span style="color: #000066;">Modified</span>=<span style="color: #ff0000;">&quot;20100205 08:40:53&quot;</span> <span style="color: #000066;">Created</span>=<span style="color: #ff0000;">&quot;20081001 01:58:47&quot;</span> <span style="color: #000066;">ServerTemplate</span>=<span style="color: #ff0000;">&quot;109&quot;</span> <span style="color: #000066;">FeatureId</span>=<span style="color: #ff0000;">&quot;00bfea71-52d4-45b3-b544-b1c71b620109&quot;</span> <span style="color: #000066;">BaseType</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;{2CDA4792-6D4E-4D9F-BC5B-F862D5235061}&quot;</span> <span style="color: #000066;">ImageUrl</span>=<span style="color: #ff0000;">&quot;/_layouts/images/itil.gif&quot;</span> <span style="color: #000066;">Description</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">Title</span>=<span style="color: #ff0000;">&quot;Images&quot;</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">&quot;{2CDA4792-6D4E-4D9F-BC5B-F862D5235061}&quot;</span> <span style="color: #000066;">MobileDefaultViewUrl</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">DefaultViewUrl</span>=<span style="color: #ff0000;">&quot;/sites/SiteCollection/SubSite1/SubSite2/Images1/Forms/AllItems.aspx&quot;</span> <span style="color: #000066;">DocTemplateUrl</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Fields<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
        ... all fields are listed here in <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Field<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> nodes<br />
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Fields<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;RegionalSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
         ...<br />
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/RegionalSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ServerSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
         ...<br />
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ServerSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/List<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/GetListResult<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/GetListResponse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Notice, the List node contains a LOT of useful information. Once we have that node, we can display a lot of it using this function:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> addListInformation<span style="color: #009900;">&#40;</span>nodeList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> listTitle <span style="color: #339933;">=</span> nodeList.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Title'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> listImg <span style="color: #339933;">=</span> nodeList.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ImageUrl'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> listDesc <span style="color: #339933;">=</span> nodeList.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Description'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> listCount <span style="color: #339933;">=</span> nodeList.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ItemCount'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> listViewURL <span style="color: #339933;">=</span> nodeList.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'DefaultViewUrl'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
<br />
   <span style="color: #003366; font-weight: bold;">var</span> output <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">+</span> listViewURL <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;&lt;img src=&quot;'</span> <span style="color: #339933;">+</span> listImg <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; alt=&quot;'</span> <span style="color: #339933;">+</span> listTitle <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; /&gt;&lt;/a&gt;&lt;/td&gt;'</span><br />
   output <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;td&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">+</span> listViewURL <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;'</span> <span style="color: #339933;">+</span> listTitle <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/a&gt;&lt;/td&gt;'</span><span style="color: #339933;">;</span><br />
   output <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;td&gt;# of items = '</span> <span style="color: #339933;">+</span> listCount <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/td&gt;'</span><span style="color: #339933;">;</span><br />
   output <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;td&gt;'</span> <span style="color: #339933;">+</span> listDesc <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/td&gt;&lt;/div&gt;&lt;/tr&gt;&lt;/table&gt;'</span><span style="color: #339933;">;</span><br />
   Element.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>bottom<span style="color: #339933;">:</span>output<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Also, since we are interested in the internal column names, we want information about each of the fields. All of the columns are listed inside the Fields node (see above). A lot of them have attributes similar to below:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Field</span> <span style="color: #000066;">FromBaseType</span>=<span style="color: #ff0000;">&quot;TRUE&quot;</span> <span style="color: #000066;">StaticName</span>=<span style="color: #ff0000;">&quot;Created&quot;</span> <span style="color: #000066;">SourceID</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/sharepoint/v3&quot;</span> <span style="color: #000066;">StorageTZ</span>=<span style="color: #ff0000;">&quot;TRUE&quot;</span> <span style="color: #000066;">DisplayName</span>=<span style="color: #ff0000;">&quot;Created&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Created&quot;</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">&quot;DateTime&quot;</span> <span style="color: #000066;">ReadOnly</span>=<span style="color: #ff0000;">&quot;TRUE&quot;</span> <span style="color: #000066;">RowOrdinal</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ColName</span>=<span style="color: #ff0000;">&quot;tp_Created&quot;</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">&quot;{8c06beca-0777-48f7-91c7-6da68bc07b69}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/Field<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Field</span> <span style="color: #000066;">FromBaseType</span>=<span style="color: #ff0000;">&quot;TRUE&quot;</span> <span style="color: #000066;">StaticName</span>=<span style="color: #ff0000;">&quot;Author&quot;</span> <span style="color: #000066;">SourceID</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/sharepoint/v3&quot;</span> <span style="color: #000066;">DisplayName</span>=<span style="color: #ff0000;">&quot;Created By&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Author&quot;</span> <span style="color: #000066;">List</span>=<span style="color: #ff0000;">&quot;UserInfo&quot;</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">&quot;User&quot;</span> <span style="color: #000066;">ReadOnly</span>=<span style="color: #ff0000;">&quot;TRUE&quot;</span> <span style="color: #000066;">RowOrdinal</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ColName</span>=<span style="color: #ff0000;">&quot;tp_Author&quot;</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">&quot;{1df5e554-ec7e-46a6-901d-d85a3881cb18}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/Field<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>So, for each of the Field nodes, we are interested in the StaticName and DisplayName attributes:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> addFieldInformation<span style="color: #009900;">&#40;</span>nodes<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>nodes.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
      Element.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span>container<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>bottom<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;No results to display.&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
      <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
   <span style="color: #009900;">&#125;</span><br />
<br />
   <span style="color: #003366; font-weight: bold;">var</span> output <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;1&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Display Name&lt;/th&gt;&lt;th&gt;Internal Name&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;'</span><span style="color: #339933;">;</span><br />
   <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
      <span style="color: #003366; font-weight: bold;">var</span> attr <span style="color: #339933;">=</span> nodes<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">attributes</span><span style="color: #339933;">;</span><br />
      <span style="color: #006600; font-style: italic;">// there are a lot more attributes, but right now only care about the Display Name</span><br />
      <span style="color: #006600; font-style: italic;">// and the internal name</span><br />
      <span style="color: #003366; font-weight: bold;">var</span> displayName <span style="color: #339933;">=</span> attr.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'DisplayName'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
      <span style="color: #003366; font-weight: bold;">var</span> internalName <span style="color: #339933;">=</span> attr.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'StaticName'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
      output <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;tr&gt;&lt;td&gt;'</span> <span style="color: #339933;">+</span> displayName <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/td&gt;&lt;td&gt;'</span> <span style="color: #339933;">+</span> internalName <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/td&gt;&lt;/tr&gt;'</span><span style="color: #339933;">;</span><br />
   <span style="color: #009900;">&#125;</span><br />
   output <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;/tbody&gt;&lt;/table&gt;'</span><span style="color: #339933;">;</span><br />
<br />
   Element.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>bottom<span style="color: #339933;">:</span>output<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>And finally, to bring it all together, we are calling these functions inside our success function:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> ajaxSuccess<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
   <span style="color: #006600; font-style: italic;">// we're going to be adding HTML so reset this to be empty</span><br />
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<br />
   <span style="color: #006600; font-style: italic;">// put it in xmlDoc to make it shorter</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> xmlDoc <span style="color: #339933;">=</span> result.<span style="color: #660066;">responseXML</span><span style="color: #339933;">;</span><br />
<br />
   <span style="color: #006600; font-style: italic;">// get the List node and show some of the attributes that are interesting</span><br />
   addListInformation<span style="color: #009900;">&#40;</span>xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;List&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
   <span style="color: #006600; font-style: italic;">// then select the Fields node and get all of its children (Field nodes)</span><br />
   addFieldInformation<span style="color: #009900;">&#40;</span>xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Fields&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">childNodes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>All together now:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span><br />
<span style="color: #00bbdd;">        &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>List Information - Kit's Utilities<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!-- Include our style reset (for fun!) and our new stylesheet --&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">link</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/reset.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">link</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/utilities.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!-- Include files used for ajax, etc --&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;scriptaculous/prototype.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ajax/SoapUtils.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ajax/SearchWSUtils.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span><br />
Event.observe(window,'load',function(){<br />
   Event.observe('btnExecute','click',Execute);<br />
});<br />
<br />
function Execute() {<br />
   $('result').innerHTML = &quot;Executing...&quot;<br />
<br />
   var txtSiteUrl = $('txtSiteURL').getValue();<br />
   var txtListName = $('txtListName').getValue();<br />
<br />
   // build parameter object<br />
   var parameters =<br />
   {<br />
      listName: txtListName<br />
   }<br />
<br />
   // create soap envelope<br />
   // can find the action and namespace from the WSDL page<br />
   // ex: http://servername/_vti_bin/Lists.asmx?op=GetList<br />
   var soap = Soap.createEnvelope(<br />
     &quot;GetList&quot;, // action<br />
     &quot;http://schemas.microsoft.com/sharepoint/soap/&quot;, // namespace<br />
     parameters);<br />
<br />
   if (!txtSiteUrl.endsWith('/')) {<br />
      txtSiteUrl += '/';<br />
   }<br />
   txtSiteUrl += '_vti_bin/Lists.asmx';<br />
<br />
   // call web service<br />
   new Ajax.Request(<br />
     txtSiteUrl,<br />
     {<br />
       method: &quot;post&quot;,<br />
       contentType: &quot;text/xml&quot;,<br />
       postBody: soap,<br />
       onSuccess: ajaxSuccess,<br />
       onFailure: ajaxError<br />
     });<br />
}<br />
<br />
function ajaxSuccess(result) {<br />
   // we're going to be adding HTML so reset this to be empty<br />
   $('result').innerHTML = &quot;&quot;;<br />
<br />
   // put it in xmlDoc to make it shorter<br />
   var xmlDoc = result.responseXML;<br />
<br />
   // get the List node and show some of the attributes that are interesting<br />
   addListInformation(xmlDoc.getElementsByTagName(&quot;List&quot;)[0]);<br />
   // then select the Fields node and get all of its children (Field nodes)<br />
   addFieldInformation(xmlDoc.getElementsByTagName(&quot;Fields&quot;)[0].childNodes);<br />
}<br />
<br />
function addListInformation(nodeList) {<br />
   var listTitle = nodeList.attributes.getNamedItem('Title').value;<br />
   var listImg = nodeList.attributes.getNamedItem('ImageUrl').value;<br />
   var listDesc = nodeList.attributes.getNamedItem('Description').value;<br />
   var listCount = nodeList.attributes.getNamedItem('ItemCount').value;<br />
   var listViewURL = nodeList.attributes.getNamedItem('DefaultViewUrl').value;<br />
<br />
   var output = '<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a>&gt;&lt;<a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;' + listViewURL + '&quot;</span>&gt;&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">img</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;' + listImg + '&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;' + listTitle + '&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span>'<br />
   output += '<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;' + listViewURL + '&quot;</span>&gt;</span>' + listTitle + '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span>';<br />
   output += '<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span># of items = ' + listCount + '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span>';<br />
   output += '<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span>' + listDesc + '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a>&gt;</span>';<br />
   Element.insert('result', {bottom:output});<br />
}<br />
<br />
function addFieldInformation(nodes) {<br />
   if (nodes.length <span style="color: #009900;">&lt;<span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span><br />
<span style="color: #009900;">      Element.insert<span style="color: #66cc66;">&#40;</span>container, <span style="color: #66cc66;">&#123;</span>bottom:<span style="color: #ff0000;">&quot;No results to display.&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</span><br />
<span style="color: #009900;">      return;</span><br />
<span style="color: #009900;">   <span style="color: #66cc66;">&#125;</span></span><br />
<br />
<span style="color: #009900;">   var output <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;1&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;</span></span>Display Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">th</span></a>&gt;&lt;<a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">th</span></a>&gt;</span>Internal Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">th</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/thead.html"><span style="color: #000000; font-weight: bold;">thead</span></a>&gt;&lt;<a href="http://december.com/html/4/element/tbody.html"><span style="color: #000000; font-weight: bold;">tbody</span></a>&gt;</span>';<br />
   for (i = 0; i <span style="color: #009900;">&lt; nodes.length; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span><br />
<span style="color: #009900;">      var attr <span style="color: #66cc66;">=</span> nodes<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.attributes;</span><br />
<span style="color: #009900;">      <span style="color: #66cc66;">//</span> there are a lot more attributes, but right now only care about the Display <span style="color: #000066;">Name</span></span><br />
<span style="color: #009900;">      <span style="color: #66cc66;">//</span> and the internal <span style="color: #000066;">name</span></span><br />
<span style="color: #009900;">      var displayName <span style="color: #66cc66;">=</span> attr.getNamedItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'DisplayName'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #000066;">value</span>;</span><br />
<span style="color: #009900;">      var internalName <span style="color: #66cc66;">=</span> attr.getNamedItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'StaticName'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #000066;">value</span>;</span><br />
<span style="color: #009900;">      output +<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'&lt;tr&gt;&lt;td&gt;</span></span>' + displayName + '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span>' + internalName + '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span>';<br />
   }<br />
   output += '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tbody.html"><span style="color: #000000; font-weight: bold;">tbody</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a>&gt;</span>';<br />
<br />
   Element.insert('result', {bottom:output});<br />
}<br />
<br />
function ajaxError(result) {<br />
   Element.insert($('result'), {bottom:'<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">span</span></a> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;color:red&quot;</span>&gt;</span>' + result.responseText + '<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span>'});<br />
}<br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span><br />
   <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;controls&quot;</span>&gt;</span><br />
      <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/fieldset.html"><span style="color: #000000; font-weight: bold;">fieldset</span></a>&gt;</span><br />
         <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/legend.html"><span style="color: #000000; font-weight: bold;">legend</span></a>&gt;</span>List Information<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/legend.html"><span style="color: #000000; font-weight: bold;">legend</span></a>&gt;</span><br />
         <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtSiteURL&quot;</span>&gt;</span>Site URL:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtSiteURL&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:400px&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://server/sites/SiteCollection/SubSite&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span><br />
         <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>Example: http://server/sites/SiteCollection/SubSite<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
         <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtListName&quot;</span>&gt;</span>List Name:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtListName&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Images&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span><br />
         <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>Example: Images<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
         <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btnExecute&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Get Columns&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/fieldset.html"><span style="color: #000000; font-weight: bold;">fieldset</span></a>&gt;</span><br />
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<br />
   <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;result&quot;</span>&gt;</span><br />
      (results)<br />
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></div>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=224&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/03/14/a-simple-ajax-app-using-sharepoint-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autopopulate a SharePoint Form from URL</title>
		<link>http://kitmenke.com/blog/2010/03/11/autopopulate-a-sharepoint-form-from-url/</link>
		<comments>http://kitmenke.com/blog/2010/03/11/autopopulate-a-sharepoint-form-from-url/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 17:28:02 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=237</guid>
		<description><![CDATA[November 10, 2010 Update: I&#8217;ve posted the sequel to this post: Autopopulate a SharePoint Form from URL (with SPUtility.js). I&#8217;ll leave the original intact just in case someone wants it, but I would highly recommend checking out the new and improved way using SPUtility.js! August 20, 2010 Update: The code below has moved to be part [...]]]></description>
			<content:encoded><![CDATA[<table class="information-bar" style="margin-bottom: 5px;" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td class="information-bar-icon-cell"><img src="http://kitmenke.com/blog/wp-content/uploads/2010/08/information.png" alt="" /></td>
<td><strong>November 10, 2010 Update:</strong> I&#8217;ve posted the sequel to this post: <a title="Permanent Link to Autopopulate a SharePoint Form from URL (with SPUtility.js)" rel="bookmark" href="http://kitmenke.com/blog/2010/11/10/autopopulate-a-sharepoint-form-from-url-with-sputility-js/">Autopopulate a SharePoint Form from URL (with SPUtility.js)</a>. I&#8217;ll leave the original intact just in case someone wants it, but I would highly recommend checking out the new and improved way using <a href="http://sputility.codeplex.com/">SPUtility.js</a>!</td>
</tr>
</tbody>
</table>
<table class="information-bar" style="margin-bottom: 5px;" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td class="information-bar-icon-cell"><img src="http://kitmenke.com/blog/wp-content/uploads/2010/08/information.png" alt="" /></td>
<td><strong>August 20, 2010 Update:</strong> The code below has moved to be part of a bigger library&#8230; check out <a href="http://sputility.codeplex.com/">SPUtility.js</a> on CodePlex!</td>
</tr>
</tbody>
</table>
<p>Original Post:<br />
This post builds off of <a href="http://kitmenke.com/blog/2009/06/02/make-a-text-field-read-only-on-editformaspx-without-spd/">my previous post </a>about making fields read only. In this case, I needed to autopopulate the NewForm.aspx with a value that gets passed to the form via URL parameters.</p>
<p><span id="more-237"></span></p>
<p>In this case, the URL that gets passed in is something like:</p>
<pre lang="text" escaped="true">/Lists/ProjectTasks/NewForm.aspx?projectID=523</pre>
<p>I wanted to take the &#8216;projectID&#8217; URL parameter and autopopulate my Project ID field with this value.</p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/03/projectid.png"><img class="alignnone size-full wp-image-238" title="Project ID field" src="http://kitmenke.com/blog/wp-content/uploads/2010/03/projectid.png" alt="" width="258" height="32" /></a></p>
<p>Additionally, we will make this field Read Only so that they can&#8217;t change the value. Lastly, do this all without SharePoint designer or C# code.</p>
<p>Stick the following code in a Content Editor on your NewForm.aspx or EditForm.aspx. (Remember you can get to edit mode by appending ToolPaneView=2 on the end, like NewForm.aspx?ToolPaneView=2)</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;script type=&quot;text/javascript&quot; src=&quot;/_layouts/1033/prototype.js&quot;&gt;&lt;/script&gt;<br />
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span><br />
<span style="color: #003366; font-weight: bold;">function</span> CustomExecuteFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
    AutopopulateInputFromURL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Project ID'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'projectID'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> AutopopulateInputFromURL<span style="color: #009900;">&#40;</span>title<span style="color: #339933;">,</span>queryParamName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
   <span style="color: #003366; font-weight: bold;">var</span> inputs <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[title=&quot;'</span> <span style="color: #339933;">+</span> title <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">!=</span> inputs <span style="color: #339933;">&amp;&amp;</span> inputs.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
        <span style="color: #003366; font-weight: bold;">var</span> input <span style="color: #339933;">=</span> inputs<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
        <span style="color: #003366; font-weight: bold;">var</span> queryParams <span style="color: #339933;">=</span> location.<span style="color: #660066;">href</span>.<span style="color: #660066;">toQueryParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>queryParams <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> queryParams<span style="color: #009900;">&#91;</span>queryParamName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
           input.<span style="color: #660066;">setValue</span><span style="color: #009900;">&#40;</span>queryParams<span style="color: #009900;">&#91;</span>queryParamName<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
           <span style="color: #003366; font-weight: bold;">var</span> label <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&lt;span&gt;&quot;</span> <span style="color: #339933;">+</span> input.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/span&gt;&quot;</span><span style="color: #339933;">;</span><br />
           Element.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span>input<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>before<span style="color: #339933;">:</span> label<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
           input.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
        <span style="color: #009900;">&#125;</span><br />
    <span style="color: #009900;">&#125;</span><br />
 <span style="color: #009900;">&#125;</span><br />
<br />
_spBodyOnLoadFunctionNames.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CustomExecuteFunction&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></div></div>
<p>Depends on <a href="http://www.prototypejs.org/">Prototype.js</a>.</p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=237&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/03/11/autopopulate-a-sharepoint-form-from-url/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Editing in SharePoint&#8217;s SPGridView</title>
		<link>http://kitmenke.com/blog/2010/02/18/editing-in-sharepoints-spgridview/</link>
		<comments>http://kitmenke.com/blog/2010/02/18/editing-in-sharepoints-spgridview/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 03:36:28 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Example]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=198</guid>
		<description><![CDATA[The goal of this post is to provide an easy to understand example of how to enable editing in an SPGridView. In this case, my datasource of choice is a SharePoint list. The way that I chose to implement editing in an SPGridView involved two classes: SimpleLogic &#8211; handles query and update operations SimpleSPGrid &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>The goal of this post is to provide an easy to understand example of how to enable editing in an SPGridView. In this case, my datasource of choice is a SharePoint list.</p>
<p>The way that I chose to implement editing in an SPGridView involved two classes:</p>
<ul>
<li><strong>SimpleLogic</strong> &#8211; handles query and update operations</li>
<li><strong>SimpleSPGrid</strong> &#8211; handles all of the setup for the ObjectDataSource and the SPGridView</li>
</ul>
<p>The main advantage for splitting the two classes is to separate all of the business logic into one class. Ideally, you should be able to completely change how the <strong>SimpleLogic </strong>class retrieves/updates data without changing the <strong>SimpleSPGrid</strong> code.</p>
<p><span id="more-198"></span></p>
<h2>The Setup</h2>
<p>In this example, our logic class is retrieving and updating data in a SharePoint list. My SharePoint list had three main columns: Title (text), Region (choice), and Total Sales (currency).</p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/02/2010-02-17-17-03-36.png"><img title="SPGridView Editing - SharePoint list" src="http://kitmenke.com/blog/wp-content/uploads/2010/02/2010-02-17-17-03-36.png" alt="SharePoint list" width="545" height="265" /></a></p>
<p>Now that I had some data to read from and write to, I was ready to create my logic class.</p>
<h2>The SimpleLogic Class</h2>
<p>The goal for the logic class was to expose all of the operations the gridview would need in order to read or update data:</p>
<ol>
<li>public DataTable Select()<br />
How do I get the data?</li>
<li>public List&lt;BoundField&gt; GetColumns()<br />
How do I display the data?</li>
<li>public void Update(Dictionary&lt;string, string&gt; data)<br />
How do I update the data?</li>
</ol>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SimpleLogic<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> LIST_NAME <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Example Sales Data&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">readonly</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> LIST_COLUMNS <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">readonly</span> <span style="color: #6666cc; font-weight: bold;">string</span> VIEW_FIELDS <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">readonly</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> DATA_KEY_NAMES <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> SPWeb _currentWeb<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> SimpleLogic<span style="color: #008000;">&#40;</span>SPWeb currentWeb<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _currentWeb <span style="color: #008000;">=</span> currentWeb<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; DATA_KEY_NAMES <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DATA_KEY_NAMES<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;ID&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; LIST_COLUMNS <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">4</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; LIST_COLUMNS<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;ID&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; LIST_COLUMNS<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; LIST_COLUMNS<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Region&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; LIST_COLUMNS<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">3</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Total_x0020_Sales&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; VIEW_FIELDS <span style="color: #008000;">=</span> GetViewFields<span style="color: #008000;">&#40;</span>LIST_COLUMNS<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> GetDataKeyNames<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> DATA_KEY_NAMES<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span>BoundField<span style="color: #008000;">&gt;</span> GetColumns<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #008000;">&lt;</span>BoundField<span style="color: #008000;">&gt;</span> fields <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>BoundField<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fields<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>GetBoundField<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ID&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// we don't want the ID field to be editable so we make it readonly</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// readonly will mean a textbox to edit it will not be shown</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fields<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">ReadOnly</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fields<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>GetBoundField<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fields<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>GetBoundField<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Region&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fields<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>GetBoundField<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Total_x0020_Sales&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> fields<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> BoundField GetBoundField<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> name<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// do not use SPBoundField (will not work with editing)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; BoundField bf <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> BoundField<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bf<span style="color: #008000;">.</span><span style="color: #0000FF;">HeaderText</span> <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bf<span style="color: #008000;">.</span><span style="color: #0000FF;">DataField</span> <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> bf<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> DataTable <span style="color: #0600FF; font-weight: bold;">Select</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SPQuery q <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPQuery<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; q<span style="color: #008000;">.</span><span style="color: #0000FF;">ViewFields</span> <span style="color: #008000;">=</span> VIEW_FIELDS<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; q<span style="color: #008000;">.</span><span style="color: #0000FF;">Query</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;Where&gt;&lt;IsNotNull&gt;&lt;FieldRef Name='Title'/&gt;&lt;/IsNotNull&gt;&lt;/Where&gt;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SPList list <span style="color: #008000;">=</span> _currentWeb<span style="color: #008000;">.</span><span style="color: #0000FF;">Lists</span><span style="color: #008000;">&#91;</span>LIST_NAME<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SPListItemCollection items <span style="color: #008000;">=</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">GetItems</span><span style="color: #008000;">&#40;</span>q<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> items<span style="color: #008000;">.</span><span style="color: #0000FF;">GetDataTable</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetViewFields<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> columns<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; StringBuilder sb <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> StringBuilder<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> field <span style="color: #0600FF; font-weight: bold;">in</span> columns<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb<span style="color: #008000;">.</span><span style="color: #0000FF;">AppendFormat</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;FieldRef Name='{0}' /&gt;&quot;</span>, field<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> sb<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Update<span style="color: #008000;">&#40;</span>Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> data<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SPList list <span style="color: #008000;">=</span> _currentWeb<span style="color: #008000;">.</span><span style="color: #0000FF;">Lists</span><span style="color: #008000;">&#91;</span>LIST_NAME<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">int</span> id <span style="color: #008000;">=</span> Int32<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>data<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;ID&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SPListItem item <span style="color: #008000;">=</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">GetItemById</span><span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> data<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Region&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> data<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Region&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Total_x0020_Sales&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> data<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Total_x0020_Sales&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>DISCLAIMER: When actually implementing the class above, you will probably need to add some sort of error handling. In order to provide a simpler example, the error handling has been omitted.</p>
<p>Once our logic class is functioning correctly, we can work on hooking it up to an SPGridView.</p>
<h2>The SimpleSPGrid Class</h2>
<p>The SimpleSPGrid class contains most of the guts that will probably be different to you. The first thing to notice is that it takes our SimpleLogic class as a parameter. This allows us to instantiate our logic class beforehand with any parameters that are needed, and then pass it into SimpleSPGrid to use.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SimpleSPGrid <span style="color: #008000;">:</span> CompositeControl<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> SimpleLogic _logic<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> ObjectDataSource _gridDS<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> SPGridView _grid<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> SimpleSPGrid<span style="color: #008000;">&#40;</span>SimpleLogic logic<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _logic <span style="color: #008000;">=</span> logic<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">sealed</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> CreateChildControls<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> GRIDID <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;grid&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> DATASOURCEID <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;gridDS&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ObjectDataSource<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">ID</span> <span style="color: #008000;">=</span> DATASOURCEID<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">TypeName</span> <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span>SimpleLogic<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AssemblyQualifiedName</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">ObjectCreating</span> <span style="color: #008000;">+=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ObjectDataSourceObjectEventHandler<span style="color: #008000;">&#40;</span>gridDS_ObjectCreating<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">SelectMethod</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Select&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// to handle updates from the grid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateMethod</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Update&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">Updating</span> <span style="color: #008000;">+=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ObjectDataSourceMethodEventHandler<span style="color: #008000;">&#40;</span>gridDS_Updating<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>_gridDS<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// create our grid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _grid <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPGridView<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _grid<span style="color: #008000;">.</span><span style="color: #0000FF;">ID</span> <span style="color: #008000;">=</span> GRIDID<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _grid<span style="color: #008000;">.</span><span style="color: #0000FF;">DataSourceID</span> <span style="color: #008000;">=</span> _gridDS<span style="color: #008000;">.</span><span style="color: #0000FF;">ID</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// link the grid to the ObjectDataSource</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _grid<span style="color: #008000;">.</span><span style="color: #0000FF;">AutoGenerateColumns</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// must be false</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// generally the primary key field(s)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// these will be passed as an input parameter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _grid<span style="color: #008000;">.</span><span style="color: #0000FF;">DataKeyNames</span> <span style="color: #008000;">=</span> _logic<span style="color: #008000;">.</span><span style="color: #0000FF;">GetDataKeyNames</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// add the column that will allow editing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CommandField command <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandField<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; command<span style="color: #008000;">.</span><span style="color: #0000FF;">ShowEditButton</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>command<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// add all of the columns in the datatable to the grid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// any column that is not readonly will be passed as an input parameter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>BoundField column <span style="color: #0600FF; font-weight: bold;">in</span> _logic<span style="color: #008000;">.</span><span style="color: #0000FF;">GetColumns</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _grid<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>column<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>_grid<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// Consolidates all of the InputParameters (values from the grid)</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// into one dictionary of values to send to the update method</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">void</span> gridDS_Updating<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, ObjectDataSourceMethodEventArgs e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> data <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>DictionaryEntry entry <span style="color: #0600FF; font-weight: bold;">in</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">InputParameters</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> value <span style="color: #008000;">=</span> entry<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">?</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">:</span> entry<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>entry<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; e<span style="color: #008000;">.</span><span style="color: #0000FF;">InputParameters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; e<span style="color: #008000;">.</span><span style="color: #0000FF;">InputParameters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&quot;</span>, data<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// When the ObjectDataSource is created, hook it up to the Logic class</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// (so that it uses the Logic class to make the Select, Update... calls)</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> gridDS_ObjectCreating<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, ObjectDataSourceEventArgs e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; e<span style="color: #008000;">.</span><span style="color: #0000FF;">ObjectInstance</span> <span style="color: #008000;">=</span> _logic<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<h2>Wrap up</h2>
<p>Now that all the hard work is done, we are ready to use the classes inside our web part. Inside the CreateChildControls of your webpart you would have the following code ( even though we have an SPWeb here, it should NOT be disposed):</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> CreateChildControls<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; SimpleLogic logic <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SimpleLogic<span style="color: #008000;">&#40;</span>SPControl<span style="color: #008000;">.</span><span style="color: #0000FF;">GetContextWeb</span><span style="color: #008000;">&#40;</span>Context<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; SimpleSPGrid grid <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SimpleSPGrid<span style="color: #008000;">&#40;</span>logic<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>grid<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>This will produce the following grid!</p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/02/2010-02-17-17-01-15.png"><img title="SPGridView Editing - List Data" src="http://kitmenke.com/blog/wp-content/uploads/2010/02/2010-02-17-17-01-15.png" alt="List Data" width="587" height="260" /></a></p>
<p>And clicking edit&#8230;</p>
<p><a href="http://kitmenke.com/blog/wp-content/uploads/2010/02/2010-02-17-17-02-00.png"><img title="SPGridView Editing - SPGridView Edit Mode" src="http://kitmenke.com/blog/wp-content/uploads/2010/02/2010-02-17-17-02-00.png" alt="SPGridView Edit Mode" width="485" height="217" /></a></p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=198&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/02/18/editing-in-sharepoints-spgridview/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Turning SharePoint SPAuditEntry Update into Create</title>
		<link>http://kitmenke.com/blog/2010/01/22/turning-sharepoint-spauditentry-update-into-create/</link>
		<comments>http://kitmenke.com/blog/2010/01/22/turning-sharepoint-spauditentry-update-into-create/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 21:42:47 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=178</guid>
		<description><![CDATA[If you&#8217;ve done any work with SharePoint and SPAuditEntry, you may have noticed the distinct lack of Create event. Instead, two Update events are created which means some extra processing is required. For example, after uploading &#8220;NewTxtFile.txt&#8221; into a document library inside one of my sites, the following Audit Entries showed up. &#60;AuditEntry&#62;     &#60;SiteId&#62;9a70a244-1baa-4229-84ac-3f06bccecc7f&#60;/SiteId&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve done any work with SharePoint and SPAuditEntry, you may have noticed the distinct lack of Create event. Instead, two Update events are created which means some extra processing is required.</p>
<p><span id="more-178"></span></p>
<p>For example, after uploading &#8220;NewTxtFile.txt&#8221; into a document library inside one of my sites, the following Audit Entries showed up.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>9a70a244-1baa-4229-84ac-3f06bccecc7f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>f332a82b-17d1-4c31-9726-5259769f2695<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>List<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sites/MySiteCollection/MySubsite/Documents<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Url<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1/22/2010 9:17:06 PM<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Update<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SharePoint<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>NewTxtFile.txt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>9a70a244-1baa-4229-84ac-3f06bccecc7f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>19ce9254-93bc-41ff-9da1-ba5e994bf1c1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Document<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sites/MySiteCollection/MySubsite/Documents/NewTxtFile.txt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Url<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1/22/2010 9:17:06 PM<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Update<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SharePoint<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Notice the &#8220;Occurred&#8221; DateTime properties are the same as well the Event. Also, one is an Update for the List and one is an Update for the Document. Using this information, you can then simplify the duplicate Update events into one Create event!</p>
<p><strong>Update 08/18/2010:</strong></p>
<p>Looks like Thomas found an easier method for determing Create events! I did some more research after seeing his comment and found the following:</p>
<ol>
<li>Creates:
<ul>
<li>Document Audit Entry: EventData is null</li>
</ul>
<ul>
<li>List Audit Entry: EventData contains document filename</li>
</ul>
</li>
<li>Edits:
<ul>
<li>Document Audit Entry: EventData contains version information</li>
</ul>
</li>
</ol>
<p>Here are the two events generated during a Create:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>9a70a244-1baa-4229-84ac-3f06bccecc7f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ca98cdba-c44f-4318-bb44-a46bd674d80f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Document<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>19<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sites/MySiteCollection/MySubsite/Documents/Test Document.doc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Url<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8/18/2010 2:21:43 PM<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Update<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SharePoint<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>9a70a244-1baa-4229-84ac-3f06bccecc7f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>28efdcba-4639-445f-80b6-31964a9f95f1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>List<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>19<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sites/MySiteCollection/MySubsite/Documents<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Url<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8/18/2010 2:21:43 PM<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Update<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SharePoint<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="display:block;background-color:#ffff66">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Test Document.doc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Here is the event that was generated after an Edit:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>9a70a244-1baa-4229-84ac-3f06bccecc7f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SiteId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ca98cdba-c44f-4318-bb44-a46bd674d80f<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Document<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>19<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/UserId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sites/MySiteCollection/MySubsite/Documents/Test Document.doc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DocLocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Url<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LocationType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8/18/2010 2:25:47 PM<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Occurred<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Update<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SharePoint<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventSource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="display:block;background-color:#ffff66">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EventData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="display:block;background-color:#ffff66">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="display:block;background-color:#ffff66">            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Major<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Major<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="display:block;background-color:#ffff66">            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Minor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Minor<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="display:block;background-color:#ffff66">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="display:block;background-color:#ffff66">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/EventData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br /></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AuditEntry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Thanks Thomas!</p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=178&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/01/22/turning-sharepoint-spauditentry-update-into-create/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AllowUnsafeUpdates and ValidateFormDigest</title>
		<link>http://kitmenke.com/blog/2009/12/23/allowunsafeupdates-and-validateformdigest/</link>
		<comments>http://kitmenke.com/blog/2009/12/23/allowunsafeupdates-and-validateformdigest/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 16:34:41 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=175</guid>
		<description><![CDATA[Add this to the list of things every SharePoint developer should know (up there with disposing SPWebs and SPSites). In general&#8230; Don&#8217;t update SharePoint objects on a GET request Call SPUtility.ValidateFormDigest() before anything on a POST request Here are the two links to read: What you need to know about AllowUnsafeUpdates (Part 1) What you need [...]]]></description>
			<content:encoded><![CDATA[<p>Add this to the list of things every SharePoint developer should know (up there with disposing SPWebs and SPSites).</p>
<p>In general&#8230;</p>
<ol>
<li>Don&#8217;t update SharePoint objects on a GET request</li>
<li>Call SPUtility.ValidateFormDigest() before anything on a POST request</li>
</ol>
<p>Here are the two links to read:</p>
<ul>
<li><a rel="bookmark" href="http://hristopavlov.wordpress.com/2008/05/16/what-you-need-to-know-about-allowunsafeupdates/">What you need to know about AllowUnsafeUpdates (Part 1)</a></li>
<li><a rel="bookmark" href="http://hristopavlov.wordpress.com/2008/05/21/what-you-need-to-know-about-allowunsafeupdates-part-2/">What you need to know about AllowUnsafeUpdates (Part 2)</a></li>
</ul>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=175&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2009/12/23/allowunsafeupdates-and-validateformdigest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internal column names: Site Columns vs List Columns</title>
		<link>http://kitmenke.com/blog/2009/12/02/internal-column-names-site-columns-vs-list-columns/</link>
		<comments>http://kitmenke.com/blog/2009/12/02/internal-column-names-site-columns-vs-list-columns/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 21:02:32 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=166</guid>
		<description><![CDATA[Two identical custom lists with the same columns. The only difference is that one list has columns added using Site Columns and the other list had columns added directly to the list. The same? Not so much&#8230; Steps to repro this issue: Create a site column named &#8220;A,B-C/D&#8221; (single line of text or any other [...]]]></description>
			<content:encoded><![CDATA[<p>Two identical custom lists with the same columns. The only difference is that one list has columns added using Site Columns and the other list had columns added directly to the list. The same? Not so much&#8230;<br />
<span id="more-166"></span></p>
<p>Steps to repro this issue:</p>
<ol>
<li>Create a site column named &#8220;A,B-C/D&#8221; (single line of text or any other type)</li>
<li>Create a list named &#8220;Special Characters (Site)&#8221;</li>
<li>Add the Site Column &#8220;A,B-C/D&#8221; to your &#8220;Special Characters (Site)&#8221; list.</li>
<li>Create another list named &#8220;Special Characters (List)&#8221;</li>
<li>Create a column in &#8220;Special Characters (List)&#8221; named the same as your site column (&#8220;A,B-C/D&#8221;)</li>
</ol>
<p>Results:</p>
<table border="1">
<tbody>
<tr>
<td> </td>
<td>Column Added Using Site Column</td>
<td>Column Created Directly in the List</td>
</tr>
<tr>
<td><strong>Column Name</strong></td>
<td>A,B-C/D</td>
<td>A,B-C/D</td>
</tr>
<tr>
<td><strong>Internal Column Name</strong></td>
<td>A_x002C_B_x002d_C_x002F_D</td>
<td>A_x002c_B_x002d_C_x002f_D</td>
</tr>
</tbody>
</table>
<p>The internal column names are DIFFERENT.</p>
<p>&#8230; but only for some of the characters. Looks like the comma and the slash are different but not the dash.</p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=166&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2009/12/02/internal-column-names-site-columns-vs-list-columns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

