<?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>Andrew Noon&#039;s Blog</title>
	<atom:link href="http://vspug.com/andynoon/feed/" rel="self" type="application/rss+xml" />
	<link>http://vspug.com/andynoon</link>
	<description>Just another VSPUG - Virtual SharePoint User Group weblog</description>
	<lastBuildDate>Tue, 08 Dec 2009 19:35:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Blog on the move</title>
		<link>http://vspug.com/andynoon/2009/12/08/blog-on-the-move/</link>
		<comments>http://vspug.com/andynoon/2009/12/08/blog-on-the-move/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 19:35:14 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vspug.com/andynoon/?p=63</guid>
		<description><![CDATA[http://andynoon.spaces.live.com]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having trouble blogging since the move to WorldPress&#8230;I&#8217;m going to start blogging on Live and see how it goes.</p>
<p>I guess I should have made the move previously given that I&#8217;m a Microsoft nut:  <a href="http://andynoon.spaces.live.com">http://andynoon.spaces.live.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2009/12/08/blog-on-the-move/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InfoPath &#8211; Bulk update forms in a SharePoint library</title>
		<link>http://vspug.com/andynoon/2009/07/30/infopath-bulk-update-forms-in-a-sharepoint-library/</link>
		<comments>http://vspug.com/andynoon/2009/07/30/infopath-bulk-update-forms-in-a-sharepoint-library/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 14:09:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[After a customer of mine ran hopelessly behind processing forms in a SharePoint library they requested a utility to automate the update all the forms in bulk.
Initially, I thought this might be a bit of a pain but once I got into it it was a pretty simple little app.
It&#8217;s written as a windows application [...]]]></description>
			<content:encoded><![CDATA[<p>After a customer of mine ran hopelessly behind processing forms in a SharePoint library they requested a utility to automate the update all the forms in bulk.</p>
<p>Initially, I thought this might be a bit of a pain but once I got into it it was a pretty simple little app.</p>
<p>It&rsquo;s written as a windows application and simply loops through each form in a library and makes updates based on your the data you enter.&nbsp; This quick and dirty app only allows 4 field updates per form but if I had the time it would be pretty simple to just do this in a repeating section so there were no limits.&nbsp; You can also choose whether you want to copy the file to another location once the update is complete.</p>
<p>&nbsp;</p>
<p>Here&rsquo;s a screenshot:</p>
<p><a href="/oldweblogfiles/andynoon/image_0ED44019.png"><img height="162" width="244" src="/oldweblogfiles/andynoon/image_thumb_1064C053.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /></a> </p>
<p>&nbsp;</p>
<p>And the code:</p>
<p>&nbsp;</p>
<p>lstItemsProcessed.Items.Clear(); <br />int i = 1; <br />SPSite objSite = new SPSite(txtSite.Text); <br />SPWeb objWeb = objSite.OpenWeb(); <br />SPList objList = objWeb.Lists[txtLibraryName.Text]; </p>
<p>foreach (SPListItem objListItem in objList.Items) <br />{ <br />&nbsp;&nbsp;&nbsp; try <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPFile objExistingFile = objListItem.File; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objExistingFile.CheckOut(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlDocument xmlFile = new XmlDocument(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlFile.Load(objExistingFile.OpenBinaryStream()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlNode xmlRootNode = xmlFile.DocumentElement; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XPathNavigator xmlNav = xmlFile.CreateNavigator(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlFile.NameTable); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nsmgr.AddNamespace(&quot;my&quot;, &quot;<a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-08-15T09:27:20&quot;);">http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-08-15T09:27:20&quot;);</a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField.Text!=&quot;&quot;) xmlRootNode.SelectSingleNode(txtField.Text, nsmgr).InnerText = txtValue.Text; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField2.Text != &quot;&quot;) xmlRootNode.SelectSingleNode(txtField2.Text, nsmgr).InnerText = txtValue2.Text; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField3.Text != &quot;&quot;) xmlRootNode.SelectSingleNode(txtField3.Text, nsmgr).InnerText = txtValue3.Text; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField4.Text != &quot;&quot;) xmlRootNode.SelectSingleNode(txtField4.Text, nsmgr).InnerText = txtValue4.Text; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strData = xmlFile.OuterXml; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemoryStream msFile = new MemoryStream(Encoding.UTF8.GetBytes(strData)); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objExistingFile.SaveBinary(msFile); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objExistingFile.CheckIn(&quot;Updated by stealth!&quot;); </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtDestinationSite.Text != &quot;&quot;) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPWeb objDestWeb = new SPSite(txtDestinationSite.Text).OpenWeb(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objDestWeb.GetFolder(txtDestinationLibrary.Text).Files.Add(objExistingFile.Name, msFile, true); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objDestWeb.Dispose(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lstItemsProcessed.Items.Add(i.ToString() + &quot;: Processed &quot; + objListItem.Name + &quot; at &quot; + DateTime.Now); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; catch (Exception exc) <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lstItemsProcessed.Items.Add(i.ToString() + &quot;: ERROR &quot; + objListItem.Name + &quot; at &quot; + DateTime.Now + &quot; -&gt; &quot; + exc.Message); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; finally <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; objWeb.Close(); <br />&nbsp;&nbsp;&nbsp; objSite.Close(); <br />&nbsp;&nbsp;&nbsp; objWeb.Dispose(); <br />&nbsp;&nbsp;&nbsp; objSite.Dispose(); </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2009/07/30/infopath-bulk-update-forms-in-a-sharepoint-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InfoPath &#8211; Bulk update forms in a SharePoint library</title>
		<link>http://vspug.com/andynoon/2009/07/30/infopath-bulk-update-forms-in-a-sharepoint-library/</link>
		<comments>http://vspug.com/andynoon/2009/07/30/infopath-bulk-update-forms-in-a-sharepoint-library/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 14:09:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[After a customer of mine ran hopelessly behind processing forms in a SharePoint library they requested a utility to automate the update all the forms in bulk.
Initially, I thought this might be a bit of a pain but once I got into it it was a pretty simple little app.
It&#8217;s written as a windows application [...]]]></description>
			<content:encoded><![CDATA[<p>After a customer of mine ran hopelessly behind processing forms in a SharePoint library they requested a utility to automate the update all the forms in bulk.</p>
<p>Initially, I thought this might be a bit of a pain but once I got into it it was a pretty simple little app.</p>
<p>It&rsquo;s written as a windows application and simply loops through each form in a library and makes updates based on your the data you enter.&nbsp; This quick and dirty app only allows 4 field updates per form but if I had the time it would be pretty simple to just do this in a repeating section so there were no limits.&nbsp; You can also choose whether you want to copy the file to another location once the update is complete.</p>
<p>&nbsp;</p>
<p>Here&rsquo;s a screenshot:</p>
<p><a href="/oldweblogfiles/andynoon/image_0ED44019.png"><img height="162" width="244" src="/oldweblogfiles/andynoon/image_thumb_1064C053.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /></a> </p>
<p>&nbsp;</p>
<p>And the code:</p>
<p>&nbsp;</p>
<p>lstItemsProcessed.Items.Clear(); <br />int i = 1; <br />SPSite objSite = new SPSite(txtSite.Text); <br />SPWeb objWeb = objSite.OpenWeb(); <br />SPList objList = objWeb.Lists[txtLibraryName.Text]; </p>
<p>foreach (SPListItem objListItem in objList.Items) <br />{ <br />&nbsp;&nbsp;&nbsp; try <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPFile objExistingFile = objListItem.File; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objExistingFile.CheckOut(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlDocument xmlFile = new XmlDocument(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlFile.Load(objExistingFile.OpenBinaryStream()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlNode xmlRootNode = xmlFile.DocumentElement; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XPathNavigator xmlNav = xmlFile.CreateNavigator(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlFile.NameTable); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nsmgr.AddNamespace(&quot;my&quot;, &quot;<a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-08-15T09:27:20&quot;);">http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-08-15T09:27:20&quot;);</a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField.Text!=&quot;&quot;) xmlRootNode.SelectSingleNode(txtField.Text, nsmgr).InnerText = txtValue.Text; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField2.Text != &quot;&quot;) xmlRootNode.SelectSingleNode(txtField2.Text, nsmgr).InnerText = txtValue2.Text; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField3.Text != &quot;&quot;) xmlRootNode.SelectSingleNode(txtField3.Text, nsmgr).InnerText = txtValue3.Text; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtField4.Text != &quot;&quot;) xmlRootNode.SelectSingleNode(txtField4.Text, nsmgr).InnerText = txtValue4.Text; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strData = xmlFile.OuterXml; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemoryStream msFile = new MemoryStream(Encoding.UTF8.GetBytes(strData)); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objExistingFile.SaveBinary(msFile); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objExistingFile.CheckIn(&quot;Updated by stealth!&quot;); </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtDestinationSite.Text != &quot;&quot;) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPWeb objDestWeb = new SPSite(txtDestinationSite.Text).OpenWeb(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objDestWeb.GetFolder(txtDestinationLibrary.Text).Files.Add(objExistingFile.Name, msFile, true); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objDestWeb.Dispose(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lstItemsProcessed.Items.Add(i.ToString() + &quot;: Processed &quot; + objListItem.Name + &quot; at &quot; + DateTime.Now); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; catch (Exception exc) <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lstItemsProcessed.Items.Add(i.ToString() + &quot;: ERROR &quot; + objListItem.Name + &quot; at &quot; + DateTime.Now + &quot; -&gt; &quot; + exc.Message); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; finally <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; objWeb.Close(); <br />&nbsp;&nbsp;&nbsp; objSite.Close(); <br />&nbsp;&nbsp;&nbsp; objWeb.Dispose(); <br />&nbsp;&nbsp;&nbsp; objSite.Dispose(); </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2009/07/30/infopath-bulk-update-forms-in-a-sharepoint-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contact Selector / People Editor</title>
		<link>http://vspug.com/andynoon/2008/12/11/contact-selector-people-editor/</link>
		<comments>http://vspug.com/andynoon/2008/12/11/contact-selector-people-editor/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 16:30:35 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I just spent far too long trying to find a blog on adding the SharePoint PeopleEditor control to InfoPath.&#160; I&#39;ve done it before but I couldn&#39;t remember how!
The controls are so similar that I didn&#39;t think the names would be different.&#160; Anyway, here&#39;s how to add the PeopleEditor / Contact Selector to InfoPath&#8230;

Click on control [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent far too long trying to find a blog on adding the SharePoint PeopleEditor control to InfoPath.&#160; I&#39;ve done it before but I couldn&#39;t remember how!</p>
<p>The controls are so similar that I didn&#39;t think the names would be different.&#160; Anyway, here&#39;s how to add the PeopleEditor / Contact Selector to InfoPath&#8230;</p>
<ul>
<li>Click on control and at the bottom select &#39;add or remove custom controls&#39;</li>
<li>Choose &#39;contact selector&#39;</li>
<li>Don&#39;t include the cab</li>
<li>Select &#39;field or group (any data type)&#39;</li>
<li>Add the following structure to your data source</li>
</ul>
<p>&#160;</p>
<p>GroupName (group)</p>
<blockquote><p>Person (group)</p>
<ul>
<li>DisplayName (text)</li>
<li>AccountId (text)</li>
<li>AccountType (text)</li>
</ul>
<p>&#160;</p>
</blockquote>
<ul>
<li>That&#39;s it, as long as you&#39;re using a web form it will inherit the context of the site.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/12/11/contact-selector-people-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contact Selector / People Editor</title>
		<link>http://vspug.com/andynoon/2008/12/11/contact-selector-people-editor/</link>
		<comments>http://vspug.com/andynoon/2008/12/11/contact-selector-people-editor/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 16:30:35 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I just spent far too long trying to find a blog on adding the SharePoint PeopleEditor control to InfoPath.&#160; I&#39;ve done it before but I couldn&#39;t remember how!
The controls are so similar that I didn&#39;t think the names would be different.&#160; Anyway, here&#39;s how to add the PeopleEditor / Contact Selector to InfoPath&#8230;

Click on control [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent far too long trying to find a blog on adding the SharePoint PeopleEditor control to InfoPath.&#160; I&#39;ve done it before but I couldn&#39;t remember how!</p>
<p>The controls are so similar that I didn&#39;t think the names would be different.&#160; Anyway, here&#39;s how to add the PeopleEditor / Contact Selector to InfoPath&#8230;</p>
<ul>
<li>Click on control and at the bottom select &#39;add or remove custom controls&#39;</li>
<li>Choose &#39;contact selector&#39;</li>
<li>Don&#39;t include the cab</li>
<li>Select &#39;field or group (any data type)&#39;</li>
<li>Add the following structure to your data source</li>
</ul>
<p>&#160;</p>
<p>GroupName (group)</p>
<blockquote><p>Person (group)</p>
<ul>
<li>DisplayName (text)</li>
<li>AccountId (text)</li>
<li>AccountType (text)</li>
</ul>
<p>&#160;</p>
</blockquote>
<ul>
<li>That&#39;s it, as long as you&#39;re using a web form it will inherit the context of the site.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/12/11/contact-selector-people-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update on setting ReadOnly status on an SPSite</title>
		<link>http://vspug.com/andynoon/2008/11/11/update-on-setting-readonly-status-on-an-spsite/</link>
		<comments>http://vspug.com/andynoon/2008/11/11/update-on-setting-readonly-status-on-an-spsite/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 08:10:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
Forgive me blog for I have sinned, it has been 6 months (or so) since my last confession and I promise not to leave it so long this time  
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
I recently had a query from an ex-colleague on a post I&#39;d written early this year when having problems setting the read only status of [...]]]></description>
			<content:encoded><![CDATA[<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Forgive me blog for I have sinned, it has been 6 months (or so) since my last confession and I promise not to leave it so long this time <img src='http://vspug.com/andynoon/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>I recently had a query from an ex-colleague on a post I&#39;d written early this year when having problems setting the read only status of a SharePoint site.&#160; The previous post is here : <a href="/andynoon/archive/2008/01/21/spsite-readonly-amp-writelocked-properties-fail-on-a-get-request.aspx" target="_blank">SPSite ReadOnly &amp; WriteLocked properties fail on a GET request</a></p>
<p>For context the application was for a controlled site creation and management process to replace/complement the site creation and permissions screens within MOSS and pre-populate sites will all sorts of funky data.&#160; I never did get a real reason why the call fails but here is a sample from the code that got around the problem&#8230;</p>
<p>&#160;</p>
<p>The HTML:
</p>
<p><span style="font-size:10pt;color:blue;font-family:;">&lt;</span><span style="font-size:10pt;color:#a31515;font-family:;">br</span><span style="font-size:10pt;font-family:;"> <span style="color:blue;">/&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;color:blue;font-family:;">&lt;</span><span style="font-size:10pt;color:#a31515;font-family:;">fieldset</span><span style="font-size:10pt;color:blue;font-family:;">&gt;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">legend</span><span style="color:blue;">&gt;</span>My Workgroups<span style="color:blue;">&lt;/</span><span style="color:#a31515;">legend</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span> <span style="color:red;">class</span><span style="color:blue;">=&quot;container&quot;&gt;&lt;</span><span style="color:#a31515;">a</span> <span style="color:red;">name</span><span style="color:blue;">=&quot;WorkgroupsICaptain&quot;&gt;&lt;/</span><span style="color:#a31515;">a</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Table</span> <span style="color:red;">ID</span><span style="color:blue;">=&quot;CaptainTable&quot;</span> <span style="color:red;">runat</span><span style="color:blue;">=&quot;server&quot;</span> <span style="color:red;">BorderWidth</span><span style="color:blue;">=&quot;0&quot;</span> <span style="color:red;">CellPadding</span><span style="color:blue;">=&quot;0&quot;</span> <span style="color:red;">CellSpacing</span><span style="color:blue;">=&quot;0&quot;</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;custom&quot;&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableHeaderRow</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Workgroup Name<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Created on<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Last Activity<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Members<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Status<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Areas<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;</span> <span style="color:red;">ColumnSpan</span><span style="color:blue;">=&quot;2&quot;&gt;</span></span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">Actions</span></b><span style="font-size:10pt;color:blue;font-family:;">&lt;/</span><span style="font-size:10pt;color:#a31515;font-family:;">asp</span><span style="font-size:10pt;color:blue;font-family:;">:</span><span style="font-size:10pt;color:#a31515;font-family:;">TableCell</span><span style="font-size:10pt;color:blue;font-family:;">&gt;<span style="">&#160; </span>//<span style="">&#160;&#160; </span>&lt;&#8212;-<span style="">&#160; </span>THIS IS WHERE THE BUTTON(S) GET DROPPED
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableHeaderRow</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Table</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;color:blue;font-family:;">&lt;/</span><span style="font-size:10pt;color:#a31515;font-family:;">fieldset</span><span style="font-size:10pt;color:blue;font-family:;">&gt;
</p>
<p>   </span></p>
<p><span style="font-size:10pt;color:blue;font-family:;">&lt;</span><span style="font-size:10pt;color:#a31515;font-family:;">br</span><span style="font-size:10pt;font-family:;"> <span style="color:blue;">/&gt;
</p>
<p>     </span></span></p>
<p><span style="font-size:10pt;color:blue;font-family:;">
<p>&#160;</p>
<p>   </span></p>
<p>Add the button&#8230;
</p>
<p>
<p>&#160;</p>
</p>
<p>&#8230;
</p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:#2b91af;">Button</span> tempBtn = <span style="color:blue;">new</span> <span style="color:#2b91af;">Button</span>();
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.CommandArgument = groups<img src="/emoticons/emotion-55.gif" alt="Idea" />.URL;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Width = 125;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Click += </span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">Call_LockSiteToggle</span></b><span style="font-size:10pt;font-family:;">;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.ID = <span style="color:#a31515;">&quot;btnToggleReadOnly&quot;</span> + i;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;">
<p>&#160;</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">if</span> (groups<img src="/emoticons/emotion-55.gif" alt="Idea" />.ReadOnly)
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Text = <span style="color:#a31515;">&quot;Make Writeable&quot;</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">else
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Text = <span style="color:#a31515;">&quot;Make Read Only&quot;</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>readonlyCell.Controls.Add(tempBtn);
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempRow.Cells.Add(readonlyCell);
</p>
<p>   </span></p>
<p>&#8230;
</p>
<p>
<p>&#160;</p>
</p>
<p>Code the button click:
</p>
<p>
<p>&#160;</p>
</p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">protected</span> <span style="color:blue;">void</span> </span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">Call_LockSiteToggle</span></b><span style="font-size:10pt;font-family:;">(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>setProperties();
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:#2b91af;">Button</span> btn = (<span style="color:#2b91af;">Button</span>)sender;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><b style="mso-bidi-font-weight:normal;">lockSiteToggle</b>(btn.CommandArgument.ToString());
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;">
<p>&#160;</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>loadWorkgroups();
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p>
<p>&#160;</p>
</p>
<p>Code the lock:
</p>
<p>
<p>&#160;</p>
</p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">private</span> <span style="color:blue;">void</span> </span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">lockSiteToggle</span></b><span style="font-size:10pt;font-family:;">(<span style="color:blue;">string</span> Url)
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>SPSecurity.RunWithElevatedPrivileges(<span style="color:blue;">delegate</span>()
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">using</span> (SPSite _SPSite = <span style="color:blue;">new</span> SPSite(Url))
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>_SPSite.AllowUnsafeUpdates = <span style="color:blue;">true</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>_SPSite.ReadOnly = !_SPSite.ReadOnly;
</p>
<p>     </span></b></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>_SPSite.AllowUnsafeUpdates = <span style="color:blue;">false</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160; </span>});
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/11/11/update-on-setting-readonly-status-on-an-spsite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update on setting ReadOnly status on an SPSite</title>
		<link>http://vspug.com/andynoon/2008/11/11/update-on-setting-readonly-status-on-an-spsite/</link>
		<comments>http://vspug.com/andynoon/2008/11/11/update-on-setting-readonly-status-on-an-spsite/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 08:10:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
Forgive me blog for I have sinned, it has been 6 months (or so) since my last confession and I promise not to leave it so long this time  
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
I recently had a query from an ex-colleague on a post I&#39;d written early this year when having problems setting the read only status of [...]]]></description>
			<content:encoded><![CDATA[<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Forgive me blog for I have sinned, it has been 6 months (or so) since my last confession and I promise not to leave it so long this time <img src='http://vspug.com/andynoon/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>I recently had a query from an ex-colleague on a post I&#39;d written early this year when having problems setting the read only status of a SharePoint site.&#160; The previous post is here : <a href="/andynoon/archive/2008/01/21/spsite-readonly-amp-writelocked-properties-fail-on-a-get-request.aspx" target="_blank">SPSite ReadOnly &amp; WriteLocked properties fail on a GET request</a></p>
<p>For context the application was for a controlled site creation and management process to replace/complement the site creation and permissions screens within MOSS and pre-populate sites will all sorts of funky data.&#160; I never did get a real reason why the call fails but here is a sample from the code that got around the problem&#8230;</p>
<p>&#160;</p>
<p>The HTML:
</p>
<p><span style="font-size:10pt;color:blue;font-family:;">&lt;</span><span style="font-size:10pt;color:#a31515;font-family:;">br</span><span style="font-size:10pt;font-family:;"> <span style="color:blue;">/&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;color:blue;font-family:;">&lt;</span><span style="font-size:10pt;color:#a31515;font-family:;">fieldset</span><span style="font-size:10pt;color:blue;font-family:;">&gt;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">legend</span><span style="color:blue;">&gt;</span>My Workgroups<span style="color:blue;">&lt;/</span><span style="color:#a31515;">legend</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span> <span style="color:red;">class</span><span style="color:blue;">=&quot;container&quot;&gt;&lt;</span><span style="color:#a31515;">a</span> <span style="color:red;">name</span><span style="color:blue;">=&quot;WorkgroupsICaptain&quot;&gt;&lt;/</span><span style="color:#a31515;">a</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Table</span> <span style="color:red;">ID</span><span style="color:blue;">=&quot;CaptainTable&quot;</span> <span style="color:red;">runat</span><span style="color:blue;">=&quot;server&quot;</span> <span style="color:red;">BorderWidth</span><span style="color:blue;">=&quot;0&quot;</span> <span style="color:red;">CellPadding</span><span style="color:blue;">=&quot;0&quot;</span> <span style="color:red;">CellSpacing</span><span style="color:blue;">=&quot;0&quot;</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;custom&quot;&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableHeaderRow</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Workgroup Name<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Created on<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Last Activity<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Members<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Status<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;&gt;</span>Areas<span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableCell</span> <span style="color:red;">CssClass</span><span style="color:blue;">=&quot;customth&quot;</span> <span style="color:red;">ColumnSpan</span><span style="color:blue;">=&quot;2&quot;&gt;</span></span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">Actions</span></b><span style="font-size:10pt;color:blue;font-family:;">&lt;/</span><span style="font-size:10pt;color:#a31515;font-family:;">asp</span><span style="font-size:10pt;color:blue;font-family:;">:</span><span style="font-size:10pt;color:#a31515;font-family:;">TableCell</span><span style="font-size:10pt;color:blue;font-family:;">&gt;<span style="">&#160; </span>//<span style="">&#160;&#160; </span>&lt;&#8212;-<span style="">&#160; </span>THIS IS WHERE THE BUTTON(S) GET DROPPED
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TableHeaderRow</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Table</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;color:blue;font-family:;">&lt;/</span><span style="font-size:10pt;color:#a31515;font-family:;">fieldset</span><span style="font-size:10pt;color:blue;font-family:;">&gt;
</p>
<p>   </span></p>
<p><span style="font-size:10pt;color:blue;font-family:;">&lt;</span><span style="font-size:10pt;color:#a31515;font-family:;">br</span><span style="font-size:10pt;font-family:;"> <span style="color:blue;">/&gt;
</p>
<p>     </span></span></p>
<p><span style="font-size:10pt;color:blue;font-family:;">
<p>&#160;</p>
<p>   </span></p>
<p>Add the button&#8230;
</p>
<p>
<p>&#160;</p>
</p>
<p>&#8230;
</p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:#2b91af;">Button</span> tempBtn = <span style="color:blue;">new</span> <span style="color:#2b91af;">Button</span>();
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.CommandArgument = groups<img src="/emoticons/emotion-55.gif" alt="Idea" />.URL;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Width = 125;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Click += </span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">Call_LockSiteToggle</span></b><span style="font-size:10pt;font-family:;">;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.ID = <span style="color:#a31515;">&quot;btnToggleReadOnly&quot;</span> + i;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;">
<p>&#160;</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">if</span> (groups<img src="/emoticons/emotion-55.gif" alt="Idea" />.ReadOnly)
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Text = <span style="color:#a31515;">&quot;Make Writeable&quot;</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">else
</p>
<p>     </span></span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempBtn.Text = <span style="color:#a31515;">&quot;Make Read Only&quot;</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>readonlyCell.Controls.Add(tempBtn);
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tempRow.Cells.Add(readonlyCell);
</p>
<p>   </span></p>
<p>&#8230;
</p>
<p>
<p>&#160;</p>
</p>
<p>Code the button click:
</p>
<p>
<p>&#160;</p>
</p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">protected</span> <span style="color:blue;">void</span> </span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">Call_LockSiteToggle</span></b><span style="font-size:10pt;font-family:;">(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>setProperties();
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:#2b91af;">Button</span> btn = (<span style="color:#2b91af;">Button</span>)sender;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><b style="mso-bidi-font-weight:normal;">lockSiteToggle</b>(btn.CommandArgument.ToString());
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;">
<p>&#160;</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>loadWorkgroups();
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p>
<p>&#160;</p>
</p>
<p>Code the lock:
</p>
<p>
<p>&#160;</p>
</p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span><span style="color:blue;">private</span> <span style="color:blue;">void</span> </span><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;">lockSiteToggle</span></b><span style="font-size:10pt;font-family:;">(<span style="color:blue;">string</span> Url)
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>SPSecurity.RunWithElevatedPrivileges(<span style="color:blue;">delegate</span>()
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">using</span> (SPSite _SPSite = <span style="color:blue;">new</span> SPSite(Url))
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>_SPSite.AllowUnsafeUpdates = <span style="color:blue;">true</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><b style="mso-bidi-font-weight:normal;"><span style="font-size:12pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>_SPSite.ReadOnly = !_SPSite.ReadOnly;
</p>
<p>     </span></b></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>_SPSite.AllowUnsafeUpdates = <span style="color:blue;">false</span>;
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160;&#160;&#160;&#160; </span>});
</p>
<p>   </span></p>
<p style="mso-layout-grid-align:none;"><span style="font-size:10pt;font-family:;"><span style="">&#160;&#160;&#160; </span>}
</p>
<p>   </span></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/11/11/update-on-setting-readonly-status-on-an-spsite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 &amp; Visual Studio 2008</title>
		<link>http://vspug.com/andynoon/2008/06/14/sql-server-2005-amp-visual-studio-2008/</link>
		<comments>http://vspug.com/andynoon/2008/06/14/sql-server-2005-amp-visual-studio-2008/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 00:02:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I was having untold problems installing a new VM.&#160; Windows 2008 with MOSS 2007, Visual Studio 2008 and SQL Server 2005.&#160; Because I was building in that order I kept having problems after installing SQL Server.&#160; Basically it didn&#39;t install the Management Studio or add the shortcut to the start menu.
&#160;I tried for a long [...]]]></description>
			<content:encoded><![CDATA[<p>I was having untold problems installing a new VM.&nbsp; Windows 2008 with MOSS 2007, Visual Studio 2008 and SQL Server 2005.&nbsp; Because I was building in that order I kept having problems after installing SQL Server.&nbsp; Basically it didn&#39;t install the Management Studio or add the shortcut to the start menu.</p>
<p>&nbsp;I tried for a long time to figure the problem out before I stumbled on a solution.&nbsp; If you change the directory name C:Program FilesMicrosoft SQL Server90Tools before you do the SQL install (it&#39;s there because VS 2008 intsalls SQL Express) then the SQL install works fine and installs the Management Studio.</p>
<p>&nbsp;I can only think that the SQL install finds the tools directory and then just assumes it doesn&#39;t need to do that bit of the install.&nbsp; More likely it tries to create the directory, get a DIRECTORYEXISTS exception and tries to resume.</p>
<p>&nbsp;Copy the old tools files back the the new tools directory when you&#39;re finished otherwise you might find VS has some problems!</p>
<p>Anyway, hope this help someone &#8211; I found nothing on google &#8211; maybe I&#39;m the only one <img src='http://vspug.com/andynoon/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/06/14/sql-server-2005-amp-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 &amp; Visual Studio 2008</title>
		<link>http://vspug.com/andynoon/2008/06/14/sql-server-2005-amp-visual-studio-2008/</link>
		<comments>http://vspug.com/andynoon/2008/06/14/sql-server-2005-amp-visual-studio-2008/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 00:02:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I was having untold problems installing a new VM.&#160; Windows 2008 with MOSS 2007, Visual Studio 2008 and SQL Server 2005.&#160; Because I was building in that order I kept having problems after installing SQL Server.&#160; Basically it didn&#39;t install the Management Studio or add the shortcut to the start menu.
&#160;I tried for a long [...]]]></description>
			<content:encoded><![CDATA[<p>I was having untold problems installing a new VM.&nbsp; Windows 2008 with MOSS 2007, Visual Studio 2008 and SQL Server 2005.&nbsp; Because I was building in that order I kept having problems after installing SQL Server.&nbsp; Basically it didn&#39;t install the Management Studio or add the shortcut to the start menu.</p>
<p>&nbsp;I tried for a long time to figure the problem out before I stumbled on a solution.&nbsp; If you change the directory name C:Program FilesMicrosoft SQL Server90Tools before you do the SQL install (it&#39;s there because VS 2008 intsalls SQL Express) then the SQL install works fine and installs the Management Studio.</p>
<p>&nbsp;I can only think that the SQL install finds the tools directory and then just assumes it doesn&#39;t need to do that bit of the install.&nbsp; More likely it tries to create the directory, get a DIRECTORYEXISTS exception and tries to resume.</p>
<p>&nbsp;Copy the old tools files back the the new tools directory when you&#39;re finished otherwise you might find VS has some problems!</p>
<p>Anyway, hope this help someone &#8211; I found nothing on google &#8211; maybe I&#39;m the only one <img src='http://vspug.com/andynoon/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/06/14/sql-server-2005-amp-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everyone wants one!</title>
		<link>http://vspug.com/andynoon/2008/03/20/everyone-wants-one/</link>
		<comments>http://vspug.com/andynoon/2008/03/20/everyone-wants-one/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 12:28:00 +0000</pubDate>
		<dc:creator>anoon</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#39;ve written so many SharePoint asset viewer type web parts (or applications) over the last few years I thought it was about time I blogged some code to get you started yourselves, the following will render a simple treeview that will allow you to traverse through your SharePoint site and sub sites and see what [...]]]></description>
			<content:encoded><![CDATA[<p>I&#39;ve written so many SharePoint asset viewer type web parts (or applications) over the last few years I thought it was about time I blogged some code to get you started yourselves, the following will render a simple treeview that will allow you to traverse through your SharePoint site and sub sites and see what lists, libraries, users etc are in each site.</p>
<pre class="csharpcode">  <a href="http://www.clearchaos.net/AndysBlogImages/Everyonewantsone_BDB3/image.png"><img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" border="0" alt="image" src="http://www.clearchaos.net/AndysBlogImages/Everyonewantsone_BDB3/image_thumb.png" width="354" height="498" /></a></pre>
<pre class="csharpcode">        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// PopulateTreeView is a recursive function, starting at the supplied SPWeb parameter it will extract all relevant information from the site before recirsing for each sub site.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name=&quot;web&quot;&gt;web is the starting SPWeb (SharePoint web site) for the function.  In this case the current site i.e. the site on which the web part is placed.&lt;/param&gt;</span>
        <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span>
        <span class="kwrd">protected</span> TreeNode PopulateTreeView(SPWeb web)
        {
            TreeNode top = <span class="kwrd">null</span>;
            <span class="kwrd">if</span> (web != <span class="kwrd">null</span>)
            {
                <span class="rem">//get detail of this current web</span>
                top = <span class="kwrd">new</span> TreeNode(<span class="str">&quot;Site Details(&quot;</span> + web.Title + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;0&quot;</span>, <span class="str">&quot;/_layouts/images/SPHOMESM.GIF&quot;</span>, web.Url, <span class="str">&quot;_blank&quot;</span>);
                TreeNode node = <span class="kwrd">new</span> TreeNode(web.Title, <span class="str">&quot;root&quot;</span>, <span class="str">&quot;/_layouts/images/ICHTT.GIF&quot;</span>, web.Url, <span class="str">&quot;_blank&quot;</span>);
                node.ChildNodes.Add(<span class="kwrd">new</span> TreeNode(<span class="str">&quot;URL: &quot;</span> + web.Url, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/NEWLINK.GIF&quot;</span>, web.Url, <span class="str">&quot;_blank&quot;</span>));
                TreeNode users = <span class="kwrd">new</span> TreeNode(<span class="str">&quot;Users&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/stsicon.gif&quot;</span>);
                <span class="rem">//get all admins</span>
                TreeNode admins = <span class="kwrd">new</span> TreeNode(<span class="str">&quot;Administrators (&quot;</span> + web.SiteAdministrators.Count + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/STSPEOPL.GIF&quot;</span>);
                <span class="kwrd">foreach</span> (SPUser user <span class="kwrd">in</span> web.SiteAdministrators)
                {
                    TreeNode usr = <span class="kwrd">new</span> TreeNode(user.LoginName + <span class="str">&quot;(&quot;</span> + user.Email + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/STAR.GIF&quot;</span>, <span class="str">&quot;mailto:&quot;</span> + user.Email, <span class="str">&quot;&quot;</span>);
                    admins.ChildNodes.Add(usr);
                }
                users.ChildNodes.Add(admins);
                <span class="rem">//get all groups and users within those groups</span>
                <span class="kwrd">foreach</span> (SPGroup group <span class="kwrd">in</span> web.Groups)
                {
                    <span class="rem">//record this group</span>
                    TreeNode grp = <span class="kwrd">new</span> TreeNode(group.Name + <span class="str">&quot; (&quot;</span> + group.Users.Count + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/STSPEOPL.GIF&quot;</span>);
                    <span class="rem">//for for each user in this group</span>
                    <span class="kwrd">foreach</span> (SPUser user <span class="kwrd">in</span> group.Users)
                    {
                        <span class="rem">//record this user</span>
                        TreeNode usr = <span class="kwrd">new</span> TreeNode(user.LoginName + <span class="str">&quot;(&quot;</span> + user.Email + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/mysite_titlegraphic.gif&quot;</span>, <span class="str">&quot;mailto:&quot;</span> + user.Email, <span class="str">&quot;&quot;</span>);
                        grp.ChildNodes.Add(usr);
                    }
                    users.ChildNodes.Add(grp);
                }
                node.ChildNodes.Add(users);
                <span class="rem">//get all lists (includes document libraries, discussion forums...)</span>
                TreeNode lists = <span class="kwrd">new</span> TreeNode(<span class="str">&quot;Lists and libraries (&quot;</span> + web.Lists.Count + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/sts_list16.gif&quot;</span>);
                <span class="kwrd">foreach</span> (SPList list <span class="kwrd">in</span> web.Lists)
                {
                    TreeNode lst = <span class="kwrd">null</span>;
                    <span class="kwrd">try</span>
                    {
                        <span class="rem">//an exception can be thrown if an attempt to get the amount of items in a list returns null, also if the list is partially defines an exception may be thrown</span>
                        lst = <span class="kwrd">new</span> TreeNode(list.Title + <span class="str">&quot; (&quot;</span> + list.ItemCount + <span class="str">&quot; items)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/iKpiList.png&quot;</span>, list.DefaultViewUrl, <span class="str">&quot;_blank&quot;</span>);
                    }
                    <span class="kwrd">catch</span>(Exception)
                    {
                        <span class="rem">//if the exception (above) was thrown, just record the name of the list (ignore the amount of items)</span>
                        lst = <span class="kwrd">new</span> TreeNode(list.Title);
                    }
                    lists.ChildNodes.Add(lst);
                }
                node.ChildNodes.Add(lists);
                <span class="rem">//recurse for each sub web of the current web</span>
                TreeNode webs = <span class="kwrd">new</span> TreeNode(<span class="str">&quot;Sub Webs (&quot;</span> + web.Webs.Count + <span class="str">&quot;)&quot;</span>, <span class="str">&quot;&quot;</span>, <span class="str">&quot;/_layouts/images/SITEVARIATION.GIF&quot;</span>);
                <span class="kwrd">foreach</span> (SPWeb subweb <span class="kwrd">in</span> web.Webs)
                {
                    webs.ChildNodes.Add(PopulateTreeView(subweb));
                }
                node.ChildNodes.Add(webs);
                top.ChildNodes.Add(node);
            }
            <span class="rem">//return the complete node</span>
            <span class="kwrd">return</span> top;
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/andynoon/2008/03/20/everyone-wants-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
