<?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>athe.la blog</title>
	<atom:link href="http://blog.athe.la/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.athe.la</link>
	<description>how to internets with style</description>
	<lastBuildDate>Wed, 25 Aug 2010 13:45:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Changing the Content Type of List Items of a List</title>
		<link>http://blog.athe.la/2010/08/changing-the-content-type-of-list-items-of-a-list/</link>
		<comments>http://blog.athe.la/2010/08/changing-the-content-type-of-list-items-of-a-list/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 13:44:01 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[content types]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=324</guid>
		<description><![CDATA[In SharePoint 2010 I came across a bug where the listitems lost their content types and reverted all the way back to being a &#8216;folder&#8217;. This was in a document library where the content types were managed by setting &#8220;Allow management of content types&#8221; to Yes in the advanced library settings. I needed a way [...]


Related posts:<ol><li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
<li><a href='http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/' rel='bookmark' title='Permanent Link: Fixing the flyout delay in the Sharepoint dynamic navigation'>Fixing the flyout delay in the Sharepoint dynamic navigation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In SharePoint 2010 I came across a bug where the listitems lost their content types and reverted all the way back to being a &#8216;folder&#8217;.  This was in a document library where the content types were managed by setting &#8220;Allow management of content types&#8221; to Yes in the advanced library settings.</p>
<p>I needed a way of iterating through every list item in the list and programmatically setting the content type to the correct one.</p>
<p>First off I made a small struct to store the path of the document library and the corresponding content type name.</p>
<pre class="brush: csharp;">
public struct ListContentTypeMapping
    {
        public string Folder;
        public string ContentType;
    }
</pre>
<p>Then I iterate through the list to change the content types.  The actual way to change content types of list items (at least in sharepoint 2010) is to change the property called &#8220;ContentTypeId&#8221; and set it to the Id (<a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttypeid.aspx">SPContentTypeId</a>) of the chosen <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttype.aspx">SPContentType</a> object.</p>
<pre class="brush: csharp;">
public void SetContentTypesOnDocumentLibraries(IEnumerable&lt;ListContentTypeMapping&gt; mappings)
	{
		using (var siteRoot = new SPSite(&quot;http://sitename/&quot;))
		{
			foreach (var mapping in mappings)
			{
				using (var web = siteRoot.RootWeb)
				{
					var list = web.GetList(mapping.Folder);

					foreach(SPListItem item in list.Items)
					{
						ChangeContentType(list, item, mapping.ContentType);
					}
				}
			}
		}
	}

private static void ChangeContentType(SPList list, SPListItem listItem, string contentTypeName)
	{
		SPContentType contentType = list.ContentTypes[contentTypeName];

		listItem[&quot;ContentTypeId&quot;] = contentType.Id;
		listItem.Update();
	}
</pre>
<p>Here&#8217;s some sample code, it will change all the items in those folders to the specific content types.</p>
<pre class="brush: csharp;">
var mappings = new List&lt;ListContentTypeMapping&gt;();
mappings.Add(new ListContentTypeMapping { Folder = &quot;some/path/to/list/&quot;, ContentType = &quot;ContentTypeOne&quot; });
mappings.Add(new ListContentTypeMapping { Folder = &quot;some/path/to/anotherlist/&quot;, ContentType = &quot;ContentTypeTwo&quot; });
SetContentTypesOnDocumentLibraries(mappings);
</pre>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
<li><a href='http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/' rel='bookmark' title='Permanent Link: Fixing the flyout delay in the Sharepoint dynamic navigation'>Fixing the flyout delay in the Sharepoint dynamic navigation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/08/changing-the-content-type-of-list-items-of-a-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing the flyout delay in the Sharepoint dynamic navigation</title>
		<link>http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/</link>
		<comments>http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 15:37:34 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[navigation]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=317</guid>
		<description><![CDATA[Sharepoint has a nasty habbit of keep navigation flyouts on the screen for a good second before they hide.  This is probably to aid accessibility where a user might not have precise mouse control.  However if you&#8217;re a good designer then you should have plenty of large clickable navigation menu items and plenty of white [...]


Related posts:<ol><li><a href='http://blog.athe.la/2009/05/dynamic-css-sprites/' rel='bookmark' title='Permanent Link: Dynamic CSS Sprites'>Dynamic CSS Sprites</a></li>
<li><a href='http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/' rel='bookmark' title='Permanent Link: Showing the Toolbox in SharePoint Designer 2010'>Showing the Toolbox in SharePoint Designer 2010</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Sharepoint has a nasty habbit of keep navigation flyouts on the screen for a good second before they hide.  This is probably to aid accessibility where a user might not have precise mouse control.  However if you&#8217;re a good designer then you should have plenty of large clickable navigation menu items and plenty of white space.</p>
<p>When rolling over a number of flyouts quickly, the user sees all the flyouts shown on the screen at once which looks rubbish.  To remove the delay altogether use this css in your page somewhere:</p>
<pre class="brush: css;">
li.hover-off&gt;ul
{
    display:none;
}
</pre>
<p>The way it works is when you hover over an item in the nav the built in sharepoint javascript adds a css class called &#8220;hover&#8221; and as soon as your mouse leaves the area it changes the class to &#8220;hover-off&#8221; for 1 second before removing it completely. This CSS will hide the unordered list directly below the list item that has the class &#8220;hover-off&#8221; thus hiding the flyout as soon as your mouse leaves the parent.</p>
<p>(P.s. this kind of flyout navigation can be set up by setting the &#8216;MaximumDynamicDisplayLevels&#8217; attribute of the SharePoint:AspMenu control)</p>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2009/05/dynamic-css-sprites/' rel='bookmark' title='Permanent Link: Dynamic CSS Sprites'>Dynamic CSS Sprites</a></li>
<li><a href='http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/' rel='bookmark' title='Permanent Link: Showing the Toolbox in SharePoint Designer 2010'>Showing the Toolbox in SharePoint Designer 2010</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Discarding a checked out file in sharepoint programmatically</title>
		<link>http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/</link>
		<comments>http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 08:46:00 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=313</guid>
		<description><![CDATA[On the SPFile object there is a method called UndoCheckOut().  This discards the checkout and returns the file or publishing page back to its original state. To discard the checkout of a publishing page do this: publishingPage.ListItem.File.UndoCheckOut(); Related posts:Programmatically Overwrite the Home Page of a SharePoint Site Uploading Files to SharePoint in Bulk Fixing the [...]


Related posts:<ol><li><a href='http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/' rel='bookmark' title='Permanent Link: Programmatically Overwrite the Home Page of a SharePoint Site'>Programmatically Overwrite the Home Page of a SharePoint Site</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
<li><a href='http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/' rel='bookmark' title='Permanent Link: Fixing the flyout delay in the Sharepoint dynamic navigation'>Fixing the flyout delay in the Sharepoint dynamic navigation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>On the SPFile object there is a method called UndoCheckOut().  This discards the checkout and returns the file or publishing page back to its original state.</p>
<p>To discard the checkout of a publishing page do this:</p>
<pre>publishingPage.ListItem.File.UndoCheckOut();</pre>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/' rel='bookmark' title='Permanent Link: Programmatically Overwrite the Home Page of a SharePoint Site'>Programmatically Overwrite the Home Page of a SharePoint Site</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
<li><a href='http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/' rel='bookmark' title='Permanent Link: Fixing the flyout delay in the Sharepoint dynamic navigation'>Fixing the flyout delay in the Sharepoint dynamic navigation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Green garbled video on youtube</title>
		<link>http://blog.athe.la/2010/08/green-garbled-video-on-youtube/</link>
		<comments>http://blog.athe.la/2010/08/green-garbled-video-on-youtube/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 22:16:17 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=311</guid>
		<description><![CDATA[Just got a new laptop and noticed a few youtube videos were green and garbled as if they had been corrupted.  I went and disabled hardware acceleration in the flash settings and now everything is fine No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Just got a new laptop and noticed a few youtube videos were green and garbled as if they had been corrupted.  I went and disabled hardware acceleration in the flash settings and now everything is fine <img src='http://blog.athe.la/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/08/green-garbled-video-on-youtube/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploading Files to SharePoint in Bulk</title>
		<link>http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/</link>
		<comments>http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 11:11:35 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=300</guid>
		<description><![CDATA[I&#8217;ve just recently attempted to upload an entire directory up to sharepoint.  I did initially try doing this using WebDAV but the speed was unimaginable slow (30 &#8211; 40 secs for a 1KB gif image).  I didn&#8217;t want to upload the images through the browser as you can only do 100 at a time (I [...]


Related posts:<ol><li><a href='http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/' rel='bookmark' title='Permanent Link: Discarding a checked out file in sharepoint programmatically'>Discarding a checked out file in sharepoint programmatically</a></li>
<li><a href='http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/' rel='bookmark' title='Permanent Link: Programmatically Overwrite the Home Page of a SharePoint Site'>Programmatically Overwrite the Home Page of a SharePoint Site</a></li>
<li><a href='http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/' rel='bookmark' title='Permanent Link: Showing the Toolbox in SharePoint Designer 2010'>Showing the Toolbox in SharePoint Designer 2010</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just recently attempted to upload an entire directory up to sharepoint.  I did initially try doing this using WebDAV but the speed was unimaginable slow (30 &#8211; 40 secs for a 1KB gif image).  I didn&#8217;t want to upload the images through the browser as you can only do 100 at a time (I had ~3,500 images plus ~4,000 documents).</p>
<p>So I looked at copying over the files using the sharepoint object model!  It turns out that this is speedy fast and works a treat!  There&#8217;s an <a href="http://msdn.microsoft.com/en-us/library/ms454491.aspx">MSDN article</a> I used as my basis but I&#8217;ve made a few changes so it uploads a whole directory instead of just a single file.  Here&#8217;s how you do it:</p>
<pre class="brush: csharp;">
public void UploadImages()
{
    this.CopyDirectory(@&quot;\\some\server\images&quot;, &quot;PublishingImages&quot;);
    this.CopyDirectory(@&quot;C:\ImagesFolder\ImagesToUpload&quot;, &quot;PublishingImages&quot;);
}

private void CopyDirectory(string frm, string to)
{
    var serveraddress = &quot;http://server:80/&quot;;
    using (var web = new SPSite(serveraddress + to).OpenWeb())
    {
        if (!web.Exists)
        {
            throw new Exception(&quot;Web doesn't exist here&quot;);
        }

        var di = new DirectoryInfo(frm);
        var fileInfos = di.GetFiles(&quot;*.*&quot;, SearchOption.TopDirectoryOnly);
        foreach (var fileInfo in fileInfos)
        {
            this.UploadFile(fileInfo.FullName, web);
        }
    }
}

private void UploadFile(string srcUrl, SPWeb web)
{
    if (!File.Exists(srcUrl))
    {
        throw new ArgumentException(String.Format(&quot;{0} does not exist&quot;,
            srcUrl), &quot;srcUrl&quot;);
    }

    byte[] contents;

    using (FileStream fStream = File.OpenRead(srcUrl))
    {
        contents = new byte[fStream.Length];
        fStream.Read(contents, 0, (int) fStream.Length);
        fStream.Close();
    }

    string filename = srcUrl.Substring(srcUrl.LastIndexOf(&quot;\\&quot;) + 1);

    if (!IsValidFileName(filename))
    {
        throw new Exception(filename + &quot; is not a valid filename.  Please review and try again.&quot;)
    }

    var file = web.Files.Add(filename, contents)
    file.Update();
}

private static bool IsValidFileName(string filename)
{
    if (filename.Contains(&quot;..&quot;) || filename.EndsWith(&quot;.&quot;) || filename.StartsWith(&quot;.&quot;))
    {
        return false;
    }

    if (filename.IndexOfAny(new[] { '\&quot;', '#', '%', '&amp;', '*', ':', '&lt;', '&gt;', '?', '\\', '/', '{', '|', '}', '~' }) &gt; -1)
    {
        return false;
    }

    if (filename.Length &gt; 128)
    {
        return false;
    }

    return true;
}
</pre>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/' rel='bookmark' title='Permanent Link: Discarding a checked out file in sharepoint programmatically'>Discarding a checked out file in sharepoint programmatically</a></li>
<li><a href='http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/' rel='bookmark' title='Permanent Link: Programmatically Overwrite the Home Page of a SharePoint Site'>Programmatically Overwrite the Home Page of a SharePoint Site</a></li>
<li><a href='http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/' rel='bookmark' title='Permanent Link: Showing the Toolbox in SharePoint Designer 2010'>Showing the Toolbox in SharePoint Designer 2010</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Bases of DateTime</title>
		<link>http://blog.athe.la/2010/07/the-bases-of-datetime/</link>
		<comments>http://blog.athe.la/2010/07/the-bases-of-datetime/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 16:50:53 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[great idea]]></category>
		<category><![CDATA[I'm just rambling]]></category>
		<category><![CDATA[Not very useful]]></category>
		<category><![CDATA[offbeat]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=294</guid>
		<description><![CDATA[Let&#8217;s say you were coding up program that required a number of base 24, how would you go about it? Think now of how you would do it in your own programming language. No really&#8230; think about it and think about the resulting type. You&#8217;re returning a string right? Depending on your programming language, you [...]


Related posts:<ol><li><a href='http://blog.athe.la/2009/04/wordbreak-filter/' rel='bookmark' title='Permanent Link: wordbreak filter'>wordbreak filter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you were coding up program that required a number of base 24, how would you go about it?  Think now of how you would do it in your own programming language.  No really&#8230; think about it and think about the resulting type.  You&#8217;re returning a string right?  Depending on your programming language, you might have gone for the approach of assuming a base 10 input, then using division and the remainder operator to go through a dictionary of strings a,b,c,A,B,C.  The type of the result is a string which is cumbersome to work with.  For example, how would you add 1 to it?  I&#8217;m guessing you&#8217;d have to convert it back to base 10, add one, then reconvert.  In my opinion that is a lot of (too much) hassle.</p>
<p>Well how about we think a little differently&#8230;  <span id="more-294"></span>We know that there are 24 hours in a day. How about we use a DateTime type to natively count using base 24?  We could initialise our datetime object at DateTime.MinValue and then use .AddHours(input) to start counting in base 24.  To increment or decrease the value we can use the .AddHours() function again to count in native base 24.  We have now got a native representation of base 24!</p>
<p>Check out this table of all the fancy bases you can get out of the DateTime type:</p>
<table>
<thead>
<tr>
<th>Base</th>
<th>Component of DateTime</th>
<th>To Add 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>am/pm</td>
<td>Add 12 hours</td>
</tr>
<tr>
<td>2</td>
<td>Whether the year is a leap year</td>
<td>Add 2 years</td>
</tr>
<tr>
<td>7</td>
<td>Days of the week</td>
<td>Add 1 day</td>
</tr>
<tr>
<td>12</td>
<td>Hours in a day in 12-hour form</td>
<td>Add 1 hour</td>
</tr>
<tr>
<td>12</td>
<td>Months in a year</td>
<td>Add 1 month</td>
</tr>
<tr>
<td>24</td>
<td>Hours in a day in 24-hour form</td>
<td>Add 1 hour</td>
</tr>
<tr>
<td>28, 29, 30, 31</td>
<td>Days in a month</td>
<td>Add 1 day</td>
</tr>
<tr>
<td>60</td>
<td>Minutes in an hour</td>
<td>Add 1 minute</td>
</tr>
<tr>
<td>75*</td>
<td>Timezones</td>
<td>Dunno mate, is there an index you could use?</td>
</tr>
<tr>
<td>365, 366</td>
<td>Days in a year</td>
<td>Add 1 day</td>
</tr>
<tr>
<td>1000</td>
<td>Milliseconds in a second</td>
<td>Add 1 millisecond</td>
</tr>
</tbody>
</table>
<p>*Number of timezones differ per operating system.  Windows has 75 I think.</p>
<p>Also, if you&#8217;re clever, you would have noticed by now that all of the above is basically useless as you will always have to use a string dictionary to get it into a form ready for saving to a db, sending to another app or displaying to the user.  This has no use other than for the sheer fun of using weird methods to calculate numbers <img src='http://blog.athe.la/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2009/04/wordbreak-filter/' rel='bookmark' title='Permanent Link: wordbreak filter'>wordbreak filter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/07/the-bases-of-datetime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatically Overwrite the Home Page of a SharePoint Site</title>
		<link>http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/</link>
		<comments>http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 11:46:20 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[easier said than done]]></category>
		<category><![CDATA[overwrite]]></category>
		<category><![CDATA[sharepoint object model]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=286</guid>
		<description><![CDATA[Imagine you are creating a page that you want in place of the default.aspx homepage that resides at the heart and soul of every Site in SharePoint.  Here&#8217;s how you do it: //pageLayout = a page layout //pubWeb = PublishingWeb PublishingPage publishingPage = pubWeb.AddPublishingPage(&#34;http://sharepointtest/justanothersite/Pages/new-default.aspx&#34;, pageLayout); publishingPage.Update(); pubWeb.DefaultPage = publishingPage.ListItem.File; pubWeb.Update(); const string checkInComment = &#34;Initial [...]


Related posts:<ol><li><a href='http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/' rel='bookmark' title='Permanent Link: Discarding a checked out file in sharepoint programmatically'>Discarding a checked out file in sharepoint programmatically</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
<li><a href='http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/' rel='bookmark' title='Permanent Link: Showing the Toolbox in SharePoint Designer 2010'>Showing the Toolbox in SharePoint Designer 2010</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Imagine you are creating a page that you want in place of the default.aspx homepage that resides at the heart and soul of every Site in SharePoint.  Here&#8217;s how you do it:</p>
<pre class="brush: csharp;">
//pageLayout = a page layout
//pubWeb = PublishingWeb

PublishingPage publishingPage = pubWeb.AddPublishingPage(&quot;http://sharepointtest/justanothersite/Pages/new-default.aspx&quot;, pageLayout);
publishingPage.Update();

pubWeb.DefaultPage = publishingPage.ListItem.File;
pubWeb.Update();

const string checkInComment = &quot;Initial Check In&quot;;
publishingPage.CheckIn(checkInComment);
SPFile pageFile = publishingPage.ListItem.File;
pageFile.Publish(checkInComment);
pageFile.Approve(checkInComment);

pageFile.MoveTo(file.ListItemAllFields.ParentList.RootFolder.Url + &quot;/default.aspx&quot;, true);
pageFile.Update();
}
</pre>
<p>The new publishing page is added to the web with the temporary url of &#8220;new-default.aspx&#8221;. Next we Update() the publishingPage to commit the add.</p>
<p>As we are adding a homepage, we set the DefaultPage property of the publishing web to the listitem file of the publishing page.  Remember here we have to Update() the publishing web or our change will not be reflected.</p>
<p>Check in and approve the file (Only appropriate if you have some kind of approval workflow set up on the site)</p>
<p>As the new publishing page we&#8217;re adding is the homepage, we use the MoveTo() method on the file to rename the file to default.aspx while passing the boolean parameter &#8216;true&#8217; to make sure it overwrites the old &#8216;default.aspx&#8217; if it is there.</p>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2010/08/discarding-a-checked-out-file-in-sharepoint-programmatically/' rel='bookmark' title='Permanent Link: Discarding a checked out file in sharepoint programmatically'>Discarding a checked out file in sharepoint programmatically</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
<li><a href='http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/' rel='bookmark' title='Permanent Link: Showing the Toolbox in SharePoint Designer 2010'>Showing the Toolbox in SharePoint Designer 2010</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Showing the Toolbox in SharePoint Designer 2010</title>
		<link>http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/</link>
		<comments>http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 11:07:22 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[sharepoint designer 2010]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=282</guid>
		<description><![CDATA[The new microsoft office ribbon hides many things, here&#8217;s one that stumped me and even my attempts to google an answer failed! If you&#8217;ve accidentally hidden the toolbox in SharePoint Designer 2010 or it&#8217;s not showing, here&#8217;s how to get it back: Go into page design view (edit a master page or page layout) and [...]


Related posts:<ol><li><a href='http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/' rel='bookmark' title='Permanent Link: Programmatically Overwrite the Home Page of a SharePoint Site'>Programmatically Overwrite the Home Page of a SharePoint Site</a></li>
<li><a href='http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/' rel='bookmark' title='Permanent Link: Fixing the flyout delay in the Sharepoint dynamic navigation'>Fixing the flyout delay in the Sharepoint dynamic navigation</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The new microsoft office ribbon hides many things, here&#8217;s one that stumped me and even my attempts to google an answer failed!</p>
<p>If you&#8217;ve accidentally hidden the toolbox in SharePoint Designer 2010 or it&#8217;s not showing, here&#8217;s how to get it back:</p>
<ol>
<li>Go into page design view (edit a master page or page layout) and click on the &#8216;Insert&#8217; tab on the ribbon.</li>
<li>Go to the SharePoint drop down.</li>
<li>At the very bottom you should see an option that says &#8216;Show  Toolbox&#8230;&#8217;.  Click it and the toolbox will reappear as if by magic!</li>
</ol>
<p><a href="http://blog.athe.la/wp-content/uploads/2010/03/toolbox-sharepoint-designer-2010.png"><img class="aligncenter size-medium wp-image-283" title="toolbox sharepoint designer 2010" src="http://blog.athe.la/wp-content/uploads/2010/03/toolbox-sharepoint-designer-2010-300x166.png" alt="" width="300" height="166" /></a></p>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2010/03/programmatically-overwrite-the-home-page-of-a-sharepoint-site/' rel='bookmark' title='Permanent Link: Programmatically Overwrite the Home Page of a SharePoint Site'>Programmatically Overwrite the Home Page of a SharePoint Site</a></li>
<li><a href='http://blog.athe.la/2010/08/fixing-the-flyout-delay-in-the-sharepoint-dynamic-navigation/' rel='bookmark' title='Permanent Link: Fixing the flyout delay in the Sharepoint dynamic navigation'>Fixing the flyout delay in the Sharepoint dynamic navigation</a></li>
<li><a href='http://blog.athe.la/2010/07/uploading-files-to-sharepoint-in-bulk/' rel='bookmark' title='Permanent Link: Uploading Files to SharePoint in Bulk'>Uploading Files to SharePoint in Bulk</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/03/showing-the-toolbox-in-sharepoint-designer-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The New Resizeable TextArea in Firefox 3.7</title>
		<link>http://blog.athe.la/2010/03/the-new-resizeable-textarea-in-firefox-3-7/</link>
		<comments>http://blog.athe.la/2010/03/the-new-resizeable-textarea-in-firefox-3-7/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 12:37:19 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=277</guid>
		<description><![CDATA[So there I was, whittering away my time on facebook when I noticed I could resize the textbox of which I was writing my useless comment.  My immediate thought was that facebook had opened up the ability to resize, but nay!  In the nightly build of firefox 3.7 (minefield) you now have the ability to [...]


Related posts:<ol><li><a href='http://blog.athe.la/2010/01/sub-pixel-rendering-hinting-in-chrome-is-inferior-to-that-of-firefox/' rel='bookmark' title='Permanent Link: Sub-Pixel Rendering (Hinting) In Chrome Is Inferior To That Of Firefox'>Sub-Pixel Rendering (Hinting) In Chrome Is Inferior To That Of Firefox</a></li>
<li><a href='http://blog.athe.la/2010/01/how-to-vertically-align-text-within-an-element/' rel='bookmark' title='Permanent Link: How to Vertically Align Text Within an Element'>How to Vertically Align Text Within an Element</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>So there I was, whittering away my time on facebook when I noticed I could resize the textbox of which I was writing my useless comment.  My immediate thought was that facebook had opened up the ability to resize, but nay!  In the nightly build of firefox 3.7 (minefield) you now have the ability to resize textareas! Sweet!  I&#8217;ve always admired it in google chrome and now us firefox lovers have it too!</p>
<div id="attachment_278" class="wp-caption aligncenter" style="width: 324px"><a href="http://blog.athe.la/wp-content/uploads/2010/03/firefox-resizeable-textarea.png"><img class="size-full wp-image-278" title="firefox resizeable textarea" src="http://blog.athe.la/wp-content/uploads/2010/03/firefox-resizeable-textarea.png" alt="" width="314" height="125" /></a><p class="wp-caption-text">In the bottom right, you see it.  The 6 dots of resizeable glory</p></div>
<p>I&#8217;m running build number 20100324040325 but this might have been available before now</p>
<p>If you&#8217;re running the latest version of firefox, check it out <a href="http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea">here</a></p>


<p>Related posts:<ol><li><a href='http://blog.athe.la/2010/01/sub-pixel-rendering-hinting-in-chrome-is-inferior-to-that-of-firefox/' rel='bookmark' title='Permanent Link: Sub-Pixel Rendering (Hinting) In Chrome Is Inferior To That Of Firefox'>Sub-Pixel Rendering (Hinting) In Chrome Is Inferior To That Of Firefox</a></li>
<li><a href='http://blog.athe.la/2010/01/how-to-vertically-align-text-within-an-element/' rel='bookmark' title='Permanent Link: How to Vertically Align Text Within an Element'>How to Vertically Align Text Within an Element</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/03/the-new-resizeable-textarea-in-firefox-3-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ExplicitCapture in Regular Expressions in .NET</title>
		<link>http://blog.athe.la/2010/03/using-explicitcapture-in-regular-expressions-in-net/</link>
		<comments>http://blog.athe.la/2010/03/using-explicitcapture-in-regular-expressions-in-net/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 12:57:40 +0000</pubDate>
		<dc:creator>Dan Cooper</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://blog.athe.la/?p=252</guid>
		<description><![CDATA[In a recent project, I&#8217;ve begun to heavily use regular expressions to capture the data from a looong string.  This post will demonstrate how I used ExplicitCapture to make it really easy to use the captured data later on using the Match object. The data is in the following format: [Data I do not care [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>In a recent project, I&#8217;ve begun to heavily use regular expressions to capture the data from a looong string.  This post will demonstrate how I used ExplicitCapture to make it really easy to use the captured data later on using the Match object.</p>
<p>The data is in the following format:</p>
<pre class="brush: plain;">
[Data I do not care about...]&lt;textarea1&gt;&lt;![CDATA[blahhhhhhh]]&gt;
&lt;/textarea1&gt; &lt;textarea2 xmlns=&quot;&quot;&gt;&lt;![CDATA[bada bing bada boom]]&gt;
&lt;/textarea2&gt;[More data I do not care about]
</pre>
<p>I need to capture all the data inside those CDATA areas, and also the number of the textarea.  Even though the content of the CDATA may be HTML and therefore <a href="http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not/590789#590789">not a regular language</a>, I am still using a regular expression here as the content outside of the textareas is regular.  If you need to extract data from HTML, I&#8217;d recommend using <a href="http://www.codeplex.com/htmlagilitypack">HTML Agility Pack</a>.</p>
<pre class="brush: csharp;">
Regex pattern = new Regex(&quot;&lt;textarea(?&lt;textareaid&gt;\\d+)( xmlns=\&quot;\&quot;|)&gt;&lt;!\\[CDATA\\[(?&lt;content&gt;.*?)\\]\\]&gt;&lt;/textarea\\d+&gt;&quot;, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
</pre>
<p>Here I&#8217;m storing my regular expression in to a variable called pattern.  The expression is a little more complex than expected due to me having to escape my backslashes when I do actually want them represented in the regex pattern.  The interesting parts are the RegexOptions in the second parameter of the Regex constructor.</p>
<p>Of course I&#8217;m using <strong>ignore case</strong> as there may be instances where the case is different.</p>
<p>I&#8217;m using <strong>single line</strong> as I don&#8217;t want to take in to account line breaks, nor am I using ^ or $ to indicate the start or end of lines respectively.  This option treats the string as one long unbroken line with line break characters and so enables a kind of <a href="http://www.regular-expressions.info/dot.html">dotall</a> functionality.</p>
<p>The final option I&#8217;m using is <strong>explicit capture</strong>. This allows me to specify which capture groups I&#8217;m actually interested in and giving them a name.  In the above example, you can see I capture the textarea id number by writing (?&lt;textareaid&gt;\\d+).  This matches one or more digits and calls it &#8220;textareaid&#8221;. Awesome.</p>
<p>Now to use that later on I use the following code:</p>
<pre class="brush: csharp;">
MatchCollection matches = pattern.Matches(content);
string convertedContent = String.Empty;
foreach (Match match in matches)
{
    convertedContent += string.Format(&quot;&lt;div id=\&quot;textarea{0}\&quot;&gt;{1}&lt;/div&gt;&quot;, match.Groups[&quot;textareaid&quot;].Value, match.Groups[&quot;content&quot;].Value);
}
</pre>
</pre>
<p>The string convertedContent will now contain as many divs as there are textareas and will contain the content held within the CDATA.  Using match.Groups["whatever"] is a really easy way to get at the match values.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.athe.la/2010/03/using-explicitcapture-in-regular-expressions-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
