<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-20777823</id><updated>2011-07-08T03:32:53.008+01:00</updated><title type='text'>Blogging is... contagious</title><subtitle type='html'>Random witterings about programming, mainly about .NET. Occasionally even contains correct info.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20777823.post-6532202696857498334</id><published>2011-04-18T09:18:00.007+01:00</published><updated>2011-04-18T09:30:02.795+01:00</updated><title type='text'>Internal Compiler Error, create your own!</title><content type='html'>You'd hope that it would be fairly difficult to make the compiler crash in Visual Studio. Sadly not. Try this one on for size:&lt;br /&gt;&lt;br /&gt;&lt;div   style="border: 1px solid black; padding: 5px;font-family:lucida console,courier new;font-size:85%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CompilerFail&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public int&lt;/span&gt;[] Numbers { &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt; { ; } }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public int&lt;/span&gt; FirstNumber { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt; { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; Numbers[0]; } }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-6532202696857498334?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/6532202696857498334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=6532202696857498334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/6532202696857498334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/6532202696857498334'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2011/04/internal-compiler-error-create-your-own.html' title='Internal Compiler Error, create your own!'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-7021168599674268341</id><published>2010-07-08T16:52:00.003+01:00</published><updated>2010-07-08T17:26:07.665+01:00</updated><title type='text'>XmlDataSource and its wonderfully helpful cache</title><content type='html'>From the looks of Google I've managed to stumble on a &lt;strike&gt;problem&lt;/strike&gt; feature that's been &lt;a href="http://dotnettemplar.net/BEWARETheEnableCachingOfXmlDataSource.aspx"&gt;causing joy&lt;/a&gt; for &lt;a href="http://www.dotnetmonster.com/Uwe/Forum.aspx/asp-net-caching/951/System-Web-UI-WebControls-XmlDataSource-caching-puzzle"&gt;many years&lt;/a&gt; already, but it's a new one on me.&lt;br /&gt;&lt;br /&gt;From the docs for &lt;a style="font-family: courier new;" href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.enablecaching.aspx"&gt;XmlDataSource.EnableCaching&lt;/a&gt; it says the following:&lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;span style="font-style: italic;"&gt;The default value is &lt;span class="input"&gt;true&lt;/span&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which is a little strange for starters given some of its siblings (e.g. &lt;a style="font-family: courier new;" href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.enablecaching.aspx"&gt;SqlDataSource&lt;/a&gt; and &lt;a style="font-family: courier new;" href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.enablecaching.aspx"&gt;ObjectDataSource&lt;/a&gt;), but OK, fair enough.&lt;br /&gt;&lt;br /&gt;It also says:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;the data source will cache data until the XML file that it depends on is  changed&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;Which would be fine, only my data source object isn't depending on a file, and I'm setting its &lt;span style="font-family:courier new;"&gt;Data&lt;/span&gt; property manually. Unfortunately, setting &lt;span style="font-family:courier new;"&gt;Data&lt;/span&gt; to what you want doesn't appear to invalidate the cache, and so you end up with what was there previously anyway.&lt;br /&gt;&lt;br /&gt;But hang on a minute - the docs for &lt;a style="font-family: courier new;" href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.data.aspx"&gt;XmlDataSource.Data&lt;/a&gt; specifically say:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;If caching is enabled and you change the value of &lt;span class="selflink"&gt;Data&lt;/span&gt;, the cache is invalidated.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;I don't believe you!&lt;br /&gt;&lt;br /&gt;Another bit of my life I'm never getting back, finding that little nugget...&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-7021168599674268341?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/7021168599674268341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=7021168599674268341' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/7021168599674268341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/7021168599674268341'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2010/07/xmldatasource-and-its-wonderfully.html' title='XmlDataSource and its wonderfully helpful cache'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-1033798364705239048</id><published>2010-05-18T21:29:00.003+01:00</published><updated>2010-05-18T21:43:47.510+01:00</updated><title type='text'>jQuery Demonstration</title><content type='html'>After a slight *cough* gap since my last post, I figured I should at least come up with something potentially useful to people this time.&lt;br /&gt;&lt;br /&gt;Having just started a new role working on a bespoke ASP.NET application, I thought I'd push the case for introducing jQuery into the codebase to help with any client-side requirements. I was asked to give a presentation it to the dev team to get their views, so I spent today coming up with a self-contained demo, using jQuery itself.&lt;br /&gt;&lt;br /&gt;I'm by no means a jQuery expert - I've essentially read half a book on the subject and &lt;span style="font-family:courier new;"&gt;slideToggle()&lt;/span&gt;d a couple of &lt;span style="font-family:courier new;"&gt;&amp;lt;div&gt;&lt;/span&gt;s before - but I came up with the rest of it in less than a day, which probably says at least a little about how easy it is to get to grips with.&lt;br /&gt;&lt;br /&gt;Anyway, without further ado... I present my short and sweet &lt;a href="http://www.diuturnal.com/jQuery/Features.html"&gt;jQuery Demonstration&lt;/a&gt;. A couple of points to note:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;You step through the demo by clicking the "jQuery" title at the top of the page;&lt;/li&gt;&lt;li&gt;You can click on the first grey markup block at any point to update it to show the current structure of the DOM;&lt;/li&gt;&lt;li&gt;When you get to the Gallery part, once the click handler has been attached to load the gallery HTML in the background, do actually click the Gallery header to load it before clicking the main jQuery title to get to the next (and final) step!&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-1033798364705239048?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/1033798364705239048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=1033798364705239048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/1033798364705239048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/1033798364705239048'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2010/05/jquery-demonstration.html' title='jQuery Demonstration'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-1672970846764860013</id><published>2007-04-27T17:30:00.001+01:00</published><updated>2007-04-27T17:36:03.862+01:00</updated><title type='text'>Manually creating an HttpRequest for testing</title><content type='html'>I'm currently writing unit tests for some code that uses the information found in the &lt;span style="font-family:courier new;"&gt;Headers&lt;/span&gt; property of an &lt;span style="font-family:courier new;"&gt;HttpRequest&lt;/span&gt; object. As such, I want to be able to create my own &lt;span style="font-family:courier new;"&gt;HttpRequest&lt;/span&gt; object with the appropriate headers.&lt;br /&gt;&lt;br /&gt;This isn't as easy as I'd like it to be, as presumably the intent for the class is that you're handed an instance of it at the appropriate time, rather than putting one together yourself (which is fair enough).&lt;br /&gt;&lt;br /&gt;Time to delve into &lt;span style="font-family:courier new;"&gt;System.Reflection&lt;/span&gt; for a bit of hacking:&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid black; padding: 5px; font-family: lucida console,courier new; font-size: 85%;"  &gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,128,0)"&gt;// Whip up a fake HttpRequest&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;HttpRequest&lt;/span&gt; httpRequest = &lt;span style="COLOR: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;HttpRequest&lt;/span&gt;(&lt;span style="COLOR: rgb(163,21,21)"&gt;"default.aspx"&lt;/span&gt;, &lt;span style="COLOR: rgb(163,21,21)"&gt;"http://www.diuturnal.com/default.aspx"&lt;/span&gt;, &lt;span style="COLOR: rgb(0,0,255)"&gt;string&lt;/span&gt;.Empty);&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,128,0)"&gt;// Have to access the Headers collection first as this creates the internal collection we're about to hack&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;NameValueCollection&lt;/span&gt; headers = httpRequest.Headers;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,128,0)"&gt;// Accessing Headers property above will have created the private _headers member, so now we can grab it&lt;/span&gt;&lt;br /&gt;headers = (&lt;span style="COLOR: rgb(43,145,175)"&gt;NameValueCollection&lt;/span&gt;) httpRequest.GetType().GetField(&lt;span style="COLOR: rgb(163,21,21)"&gt;"_headers"&lt;/span&gt;, &lt;span style="COLOR: rgb(43,145,175)"&gt;BindingFlags&lt;/span&gt;.NonPublic | &lt;span style="COLOR: rgb(43,145,175)"&gt;BindingFlags&lt;/span&gt;.Instance).GetValue(httpRequest);&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;PropertyInfo&lt;/span&gt; readOnlyInfo = headers.GetType().GetProperty(&lt;span style="COLOR: rgb(163,21,21)"&gt;"IsReadOnly"&lt;/span&gt;, &lt;span style="COLOR: rgb(43,145,175)"&gt;BindingFlags&lt;/span&gt;.NonPublic | &lt;span style="COLOR: rgb(43,145,175)"&gt;BindingFlags&lt;/span&gt;.Instance);&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,128,0)"&gt;// Hack the collection to not be read-only then add some headers&lt;/span&gt;&lt;br /&gt;readOnlyInfo.SetValue(headers, &lt;span style="COLOR: rgb(0,0,255)"&gt;false&lt;/span&gt;, &lt;span style="COLOR: rgb(0,0,255)"&gt;null&lt;/span&gt;);&lt;br /&gt;headers[&lt;span style="COLOR: rgb(163,21,21)"&gt;"Accept"&lt;/span&gt;] = &lt;span style="COLOR: rgb(163,21,21)"&gt;"text/xml,application/xml,application/xhtml+xml,text/html;&lt;br /&gt;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"&lt;/span&gt;;&lt;br /&gt;headers[&lt;span style="COLOR: rgb(163,21,21)"&gt;"User-Agent"&lt;/span&gt;] = &lt;span style="COLOR: rgb(163,21,21)"&gt;"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,128,0)"&gt;// Finished hacking, set it back to read-only&lt;/span&gt;&lt;br /&gt;readOnlyInfo.SetValue(headers, &lt;span style="COLOR: rgb(0,0,255)"&gt;true&lt;/span&gt;, &lt;span style="COLOR: rgb(0,0,255)"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Job done!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-1672970846764860013?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/1672970846764860013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=1672970846764860013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/1672970846764860013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/1672970846764860013'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2007/04/manually-creating-httprequest-for.html' title='Manually creating an HttpRequest for testing'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-6408354807709234585</id><published>2007-03-20T16:52:00.000Z</published><updated>2007-03-21T14:19:58.538Z</updated><title type='text'>UpdatePanel still performing full postback</title><content type='html'>Had some fun tracking this one down today, fortunately someone else had already done the hard work in working out how to fix it.&lt;br /&gt;&lt;br /&gt;Essentially I was trying out a basic AJAX page in an existing 2.0 web application project. The various additional required sections were added to the web.config and I followed the &lt;a href="http://ajax.asp.net/docs/tutorials/IntroductionUpdatePanel.aspx"&gt;Introduction to the UpdatePanel control&lt;/a&gt;, where a label is updated when you click a button.&lt;br /&gt;&lt;br /&gt;Simple. Or so you'd think. No AJAX behaviour for me - it was performing a full postback.&lt;br /&gt;&lt;br /&gt;Fortunately I managed to find a &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/01/23/asp-net-ajax-1-0-released.aspx#1502068"&gt;post from "Rick"&lt;/a&gt; that explained what the culprit was - the &lt;span style="font-family: courier new;"&gt;&amp;lt;xhtmlConformance mode="Legacy"/&amp;gt;&lt;/span&gt; in the web.config. Commenting this out gives the desired behaviour.&lt;br /&gt;&lt;br /&gt;I must admit I haven't bothered investigating any further to work out &lt;i&gt;why&lt;/i&gt; that works - feel free to let me know.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update:&lt;/b&gt;&lt;br /&gt;Found &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx"&gt;another post about this&lt;/a&gt; that explains a bit more from Scott Guthrie.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-6408354807709234585?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/6408354807709234585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=6408354807709234585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/6408354807709234585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/6408354807709234585'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2007/03/updatepanel-still-performing-full.html' title='UpdatePanel still performing full postback'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-2601672733290475034</id><published>2007-03-06T10:05:00.000Z</published><updated>2007-03-06T10:09:38.414Z</updated><title type='text'>Selecting random records from a database table</title><content type='html'>A little nugget I picked up from my colleague &lt;a href="http://weblogs.asp.net/wim/"&gt;Wim&lt;/a&gt; today, that was actually &lt;a href="http://weblogs.asp.net/wim/archive/2004/04/01/105906.aspx"&gt;his first blog post&lt;/a&gt; a few years back.&lt;br /&gt;&lt;br /&gt;Need a random sample of data from your database? Try this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new"&gt;SELECT TOP 10 * FROM Orders ORDER BY NEWID()&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-2601672733290475034?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/2601672733290475034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=2601672733290475034' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/2601672733290475034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/2601672733290475034'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2007/03/selecting-random-records-from-database.html' title='Selecting random records from a database table'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-1483514515755881276</id><published>2007-03-02T15:39:00.000Z</published><updated>2007-03-06T10:12:48.023Z</updated><title type='text'>DeflateStream and zlib headers</title><content type='html'>The &lt;span style="font-family:courier new;"&gt;DeflateStream&lt;/span&gt; class in &lt;span style="font-family:courier new;"&gt;System.IO.Compression&lt;/span&gt;, as the docs state, represents the DEFLATE algorithm as in &lt;a href="http://www.ietf.org/rfc/rfc1951.txt"&gt;RFC 1951&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;What it doesn't do (out of the box) is support compressed data in zlib format (see &lt;a href="http://www.ietf.org/rfc/rfc1950.txt"&gt;RFC 1950&lt;/a&gt;). When trying to decompress existing data, the easiest way I've found to get round this is simply to get rid of the 2 byte zlib header and use what's left, so something like the following works nicely if you've already got the data as a byte array in memory:&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid black; padding: 5px; font-family: lucida console,courier new; font-size: 85%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Array&lt;/span&gt;.Copy(zlibBytes, 2, strippedBytes, 0, zlibBytes.Length - 2);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Then just use the &lt;span style="font-family:courier new;"&gt;strippedBytes&lt;/span&gt; with &lt;span style="font-family:courier new;"&gt;DeflateStream&lt;/span&gt; instead.&lt;br /&gt;&lt;br /&gt;Out of interest, I also tried stripping off the 4 byte Adler-32 checksum footer, and &lt;span style="font-family:courier new;"&gt;DeflateStream&lt;/span&gt; worked happily with that too.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-1483514515755881276?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/1483514515755881276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=1483514515755881276' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/1483514515755881276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/1483514515755881276'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2007/03/deflatestream-and-zlib-headers.html' title='DeflateStream and zlib headers'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-993677549285065775</id><published>2007-02-23T15:14:00.000Z</published><updated>2007-02-23T15:30:15.655Z</updated><title type='text'>Defining values in enums</title><content type='html'>I got caught out earlier with something not working as I expected. It may well be documented behaviour somewhere, but I've not been able to find anything specifically mentioning it following a brief search, so I thought I'd document it.&lt;br /&gt;&lt;br /&gt;In an attempt to follow the guidelines for declaring an enum, specifically, placing the values in alphabetical order and providing a default "zero value", I came up with the following:&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid black; padding: 5px;font-family:lucida console,courier new;font-size:85%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Decision&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;Accept,&lt;br /&gt;&amp;nbsp;&amp;nbsp;Error,&lt;br /&gt;&amp;nbsp;&amp;nbsp;Reject,&lt;br /&gt;&amp;nbsp;&amp;nbsp;Unknown = 0&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately this leads to the following values being assigned:&lt;br /&gt;Accept = 0&lt;br /&gt;Error = 1&lt;br /&gt;Reject = 2&lt;br /&gt;Unknown = 0&lt;br /&gt;&lt;br /&gt;and thus Accept and Unknown become one and the same.&lt;br /&gt;&lt;br /&gt;Make sure that any that are declared with a value go above any that aren't!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-993677549285065775?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/993677549285065775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=993677549285065775' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/993677549285065775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/993677549285065775'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2007/02/defining-values-in-enums.html' title='Defining values in enums'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-115822880731389952</id><published>2006-09-14T11:00:00.000+01:00</published><updated>2006-09-14T11:13:27.323+01:00</updated><title type='text'>Login failures with ASP.NET 2.0 Membership</title><content type='html'>I sometimes end up with a puzzled look on my face after trying to log into one of my web applications and getting a "login failed" message back despite being sure I've got the username and password right. The usual culprit is that I've forgotten to change the applicationName attribute in the config for the Membership section (explained nicely in a post by &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/04/22/Always-set-the-_2200_applicationName_2200_-property-when-configuring-ASP.NET-2.0-Membership-and-other-Providers.aspx"&gt;Scott Guthrie&lt;/a&gt;), but despite checking and re-checking when I had the same problem yesterday, it just wouldn't let me log in.&lt;br /&gt;&lt;br /&gt;I started doing some tests, and found that if I wrote the code to do so, it would happily retrieve the password for a given username for me, but if I then used that same username and password in a call to &lt;span style="font-family: courier new;"&gt;Membership.ValidateUser() &lt;/span&gt;it still failed.&lt;br /&gt;&lt;br /&gt;To cut a long story short, the problem turned out to be that the transaction log for the database was full, and the disk had run out of space. As such it's one of those rare occurrences that you may never encounter, but as it's rather obscure and there's no indication of what the problem is when the login attempt fails, maybe this post will help someone with the same issue one day.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-115822880731389952?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/115822880731389952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=115822880731389952' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/115822880731389952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/115822880731389952'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/09/login-failures-with-aspnet-20.html' title='Login failures with ASP.NET 2.0 Membership'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-115632808004775554</id><published>2006-08-23T11:12:00.000+01:00</published><updated>2006-08-23T11:14:40.060+01:00</updated><title type='text'>Changing owner in SQL Server</title><content type='html'>Given the number of times I've ended up having to search for this and promptly forgotten it 5 minutes later, I thought I'd put this up here so I know where to find it.&lt;br /&gt;&lt;br /&gt;In order to change the owner of an object in SQL Server, use something like the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;sp_changeobjectowner 'Database.dbo.Table', 'newowner'&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-115632808004775554?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/115632808004775554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=115632808004775554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/115632808004775554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/115632808004775554'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/08/changing-owner-in-sql-server.html' title='Changing owner in SQL Server'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-115435347041047512</id><published>2006-07-31T14:34:00.000+01:00</published><updated>2006-07-31T14:44:30.730+01:00</updated><title type='text'>Resolving links from the application root</title><content type='html'>One of the things that I've got used to taking for granted is the ability to use the tilde (~) to specify the application root when specifying a link, in a &lt;span style="font-family: courier new;"&gt;HyperLink&lt;/span&gt; control, for example. Having recently ventured into the realm of writing my own controls I need to parse links like this for myself.&lt;br /&gt;&lt;br /&gt;A quick Google later and it looks like the &lt;span style="font-family: courier new;"&gt;Control.ResolveUrl()&lt;/span&gt; method is the way to go, although as an aside, there appears to be a new &lt;span style="font-family: courier new;"&gt;Control.ResolveClientUrl()&lt;/span&gt; method in 2.0 as well. The docs don't really go out of their way to explain the difference as far as I can tell, but from my own tests it would appear that the former will provide an absolute path (using the &lt;span style="font-family: courier new;"&gt;TemplateSourceDirectory&lt;/span&gt; property according to the docs), whereas the latter will give you a relative path.&lt;br /&gt;&lt;br /&gt;Quick example:&lt;br /&gt;From a page at /WebApp/dir/page.aspx that wants to create a link to "~/otherdir/link.html":&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ResolveUrl()&lt;/span&gt; gives: /WebApp/otherdir/link.html&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ResolveClientUrl()&lt;/span&gt; gives: ../otherdir/link.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-115435347041047512?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/115435347041047512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=115435347041047512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/115435347041047512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/115435347041047512'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/07/resolving-links-from-application-root.html' title='Resolving links from the application root'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-114972438060752756</id><published>2006-06-08T00:52:00.000+01:00</published><updated>2006-06-08T01:04:01.426+01:00</updated><title type='text'>Databinding with a LoginView inside a FormView</title><content type='html'>No posts at all in April and now two within a day. Go figure.&lt;br /&gt;&lt;br /&gt;I'm not sure if the title I've picked is the best way to describe this but it'll do. I've been using a &lt;span style="font-family:courier new;"&gt;LoginView&lt;/span&gt; within the &lt;span style="font-family:courier new;"&gt;ItemTemplate&lt;/span&gt; of a &lt;span style="font-family:courier new;"&gt;FormView&lt;/span&gt; to determine what the "available actions" are for a page. Here's an example:&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid black; padding: 5px;font-family:lucida console;font-size:85%;background-color:white;"&gt;&lt;br /&gt;&amp;lt;asp:FormView ID="fvApplication" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;h1&amp;gt;Application Form&amp;lt;/h1&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!-- Lots of detail about application in here --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:LoginView ID="lvOptions" runat="server"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;RoleGroups&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:RoleGroup Roles="Provider"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ContentTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:LinkButton runat="server" OnClick="Offer_Click"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Visible='&amp;lt;%# ApplicationStatus.Sent == (ApplicationStatus) Eval("Status") %&amp;gt;'&amp;gt;Make Offer&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:LinkButton runat="server" OnClick="Reject_Click"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Visible='&amp;lt;%# ApplicationStatus.Sent == (ApplicationStatus) Eval("Status") %&amp;gt;'&amp;gt;Reject Application&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/ContentTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/asp:RoleGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:RoleGroup Roles="Student"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ContentTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:LinkButton runat="server" OnClick="Send_Click"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Visible='&amp;lt;%# ApplicationStatus.Unsent == (ApplicationStatus) Eval("Status") %&amp;gt;'&amp;gt;Send&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:LinkButton runat="server" OnClick="Accept_Click"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Visible='&amp;lt;%# ApplicationStatus.Offered == (ApplicationStatus) Eval("Status") %&amp;gt;'&amp;gt;Accept Offer&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:LinkButton runat="server" OnClick="Refuse_Click"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Visible='&amp;lt;%# ApplicationStatus.Offered == (ApplicationStatus) Eval("Status") %&amp;gt;'&amp;gt;Refuse Offer&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/ContentTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/asp:RoleGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/RoleGroups&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/asp:LoginView&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;&amp;lt;/asp:FormView&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This works fine when first coming into the page. The &lt;span style="font-family:courier new;"&gt;LoginView&lt;/span&gt; picks out the right template depending on the user's role, and when my &lt;span style="font-family:courier new;"&gt;Application&lt;/span&gt; object is databound to the &lt;span style="font-family:courier new;"&gt;FormView&lt;/span&gt;, the visibility of the individual buttons is set correctly. (Note that this is my own custom &lt;span style="font-family:courier new;"&gt;Application&lt;/span&gt; object, nothing to do with the framework.)&lt;br /&gt;&lt;br /&gt;However, all is not well when making some changes to the application elsewhere on the page and then rebinding the &lt;span style="font-family:courier new;"&gt;FormView&lt;/span&gt; (i.e. this time we're dealing with a postback). This time, the &lt;span style="font-family:courier new;"&gt;LoginView&lt;/span&gt; fires its &lt;span style="font-family:courier new;"&gt;ViewChanging&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;ViewChanged&lt;/span&gt; events. I guess technically it's correct, as what I'm looking at on the page (i.e. my "view") may have changed if the various button visibilities have changed. However, my role hasn't changed, and hence the template the &lt;span style="font-family:courier new;"&gt;LoginView&lt;/span&gt; is using hasn't changed, which is kind of what I was expecting the &lt;span style="font-family:courier new;"&gt;ViewChanged&lt;/span&gt; event to mean.&lt;br /&gt;&lt;br /&gt;Anyway, the problem comes in that somewhere in the middle of this "ooh, my view's changed" moment that the &lt;span style="font-family:courier new;"&gt;LoginView&lt;/span&gt; has, it blats its control hierarchy and recreates it, only this happens after the &lt;span style="font-family:courier new;"&gt;FormView&lt;/span&gt; was databound, and thus all the button visibilities are lost, resulting in them all going back to their default setting.&lt;br /&gt;&lt;br /&gt;My workaround for now is to perform a &lt;span style="font-family:courier new;"&gt;Response.Redirect()&lt;/span&gt; and let everything create itself from scratch again as the way my page is setup allows this without any problems. However, if you need to remain within the context of a postback, I suggest using something like a &lt;span style="font-family:courier new;"&gt;MultiView&lt;/span&gt; instead of a &lt;span style="font-family:courier new;"&gt;LoginView&lt;/span&gt;, and manually set the correct view in there yourself at an appropriate time.&lt;br /&gt;&lt;br /&gt;Suggestions for better solutions are, as always, welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-114972438060752756?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/114972438060752756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=114972438060752756' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114972438060752756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114972438060752756'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/06/databinding-with-loginview-inside.html' title='Databinding with a LoginView inside a FormView'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-114968009629159826</id><published>2006-06-07T12:20:00.000+01:00</published><updated>2006-06-07T12:39:04.216+01:00</updated><title type='text'>NextStepIndex in a Wizard control</title><content type='html'>I've been using one of the new(ish) 2.0 Wizard controls in a project and it's been working nicely. That is, until I wanted to change it so that for one of the steps, you could leap out to a different page, update some other stuff, and then leap back in again to the step you were at before.&lt;br /&gt;&lt;br /&gt;When coming back to the page and starting off at step number 2, I found that clicking the previous button didn't take me to step 1 as I expected (and wanted). A quick bit of breakpoint-setting and debugging later, I found that in the event handler, the &lt;span style="font-family:courier new;"&gt;NextStepIndex&lt;/span&gt; wasn't 0 (i.e. the first step), it was 1. Thus clicking the previous button simply left me on the second step.&lt;br /&gt;&lt;br /&gt;This actually makes complete sense when placed in context, which a post on &lt;a href="http://forums.asp.net/thread/1235981.aspx"&gt;this thread&lt;/a&gt; was able to do for me. It's not previous in the sense of the last physical step as laid out in the .aspx file; it's previous in the sense of the last step in the history of your moves through the wizard. Since I was effectively starting off with a fresh copy of the wizard when coming back to the page, there was no history, and thus there was no previous step for me to go back to.&lt;br /&gt;&lt;br /&gt;In the end, the solution is simply to specify what step you want next based on the &lt;span style="font-family:courier new;"&gt;CurrentStepIndex&lt;/span&gt; in the relevant event handler. Simple!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-114968009629159826?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/114968009629159826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=114968009629159826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114968009629159826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114968009629159826'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/06/nextstepindex-in-wizard-control.html' title='NextStepIndex in a Wizard control'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-114770372241671211</id><published>2006-05-15T15:30:00.000+01:00</published><updated>2006-05-15T15:35:22.430+01:00</updated><title type='text'>Membership configuration in ASP.NET 2.0</title><content type='html'>Fine work on the documentation for this one. The documentation for &lt;span style="font-family: courier new"&gt;Membership.MinRequiredNonAlphanumericCharacters&lt;/span&gt; suggests that the attribute in the &lt;span style="font-family: courier new"&gt;&amp;lt;add&amp;gt;&lt;/span&gt; element when defining a provider should be &lt;span style="font-family: courier new"&gt;minAlphanumericCharacters&lt;/span&gt;, or alternatively &lt;span style="font-family: courier new"&gt;minRequiredNonAlphanumericCharacters&lt;/span&gt;, depending on which bit of the page you read.&lt;br /&gt;&lt;br /&gt;In fact neither of these work, and you should use &lt;span style="font-family: courier new"&gt;minRequiredNonalphanumericCharacters&lt;/span&gt; instead.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-114770372241671211?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/114770372241671211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=114770372241671211' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114770372241671211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114770372241671211'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/05/membership-configuration-in-aspnet-20.html' title='Membership configuration in ASP.NET 2.0'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-114261937750607437</id><published>2006-03-17T17:47:00.000Z</published><updated>2006-05-04T13:28:20.930+01:00</updated><title type='text'>UK Postcode Implementation</title><content type='html'>I've been meaning to put this up here ever since the day after my &lt;a href="http://kntajus.blogspot.com/2006/02/undocumented-regular-expression.html"&gt;post about regular expressions&lt;/a&gt; but time has eluded me until now. I had a stab at coming up with some code for a postcode to save doing the same old checking (or alternatively none at all!) every time; let me know what you think.&lt;br /&gt;&lt;br /&gt;Depending on how big your monitor is (and hence how wide you've likely got your browser) the &lt;span style="font-family:courier new;"&gt;ValidationString&lt;/span&gt; might wrap round - obviously this is all on one line.&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid black; padding: 5px;font-family:lucida console,courier new;font-size:85%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; Diuturnal.Utility {&lt;br /&gt;&amp;nbsp;&amp;nbsp;[&lt;span style="color: rgb(43, 145, 175);"&gt;Serializable&lt;/span&gt;]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public struct&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;private const string&lt;/span&gt; ValidationString =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(163, 21, 21);"&gt;@"^\s*(?&amp;lt;out&amp;gt;[A-Z]{1,2}[0-9R][0-9A-Z]?) *(?&amp;lt;in&amp;gt;[0-9][A-Z-[CIKMOV]]{2})\s*$"&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;private static readonly&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Regex&lt;/span&gt; _validator =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Regex&lt;/span&gt;(ValidationString);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public static readonly&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; Empty =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.Empty, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.Empty);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;private string&lt;/span&gt; _outCode;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;private string&lt;/span&gt; _inCode;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; outCode, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; inCode) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_outCode = outCode;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_inCode = inCode;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public override string&lt;/span&gt; ToString() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (0 == _outCode.Length) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return string&lt;/span&gt;.Empty;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; _outCode + " " + _inCode;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public override bool&lt;/span&gt; Equals(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; obj) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!(obj is &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt; == (&lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;) obj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public override int&lt;/span&gt; GetHashCode() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return this&lt;/span&gt;.ToString().GetHashCode();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public static bool operator&lt;/span&gt; ==(&lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; lhs, &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; rhs) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (lhs.ToString() == rhs.ToString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public static bool operator&lt;/span&gt; !=(&lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; lhs, &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; rhs) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; !(lhs == rhs);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public static&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; Parse(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; s) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt; == s) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;throw new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ArgumentNullException&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; capitalised = s.ToUpper();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (!_validator.IsMatch(capitalised)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;throw new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;FormatException&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;(_validator.Replace(capitalised, &lt;span style="color: rgb(163, 21, 21);"&gt;"${out}"&lt;/span&gt;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_validator.Replace(capitalised, &lt;span style="color: rgb(163, 21, 21);"&gt;"${in}"&lt;/span&gt;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public static bool&lt;/span&gt; TryParse(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; s, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt; result) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt; == s) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;.Empty;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; capitalised = s.ToUpper();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!_validator.IsMatch(capitalised)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;.Empty;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Postcode&lt;/span&gt;(_validator.Replace(capitalised, &lt;span style="color: rgb(163, 21, 21);"&gt;"${out}"&lt;/span&gt;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_validator.Replace(capitalised, &lt;span style="color: rgb(163, 21, 21);"&gt;"${in}"&lt;/span&gt;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-114261937750607437?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/114261937750607437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=114261937750607437' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114261937750607437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114261937750607437'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/03/uk-postcode-implementation.html' title='UK Postcode Implementation'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-114080138054635949</id><published>2006-02-24T17:06:00.000Z</published><updated>2006-02-24T17:16:20.593Z</updated><title type='text'>Undocumented regular expression pattern</title><content type='html'>UK Postcode validation is the theme for me today, and the &lt;a href="http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode.htm"&gt;standard&lt;/a&gt; has been very useful. Digging a little deeper even provides a couple of regular expression patterns for doing the validation with, both a simple one and a more complicated one.&lt;br /&gt;&lt;br /&gt;Examining the patterns has led me to a construct that I can't find documented anywhere. I've looked through all the linked pages in the "Regular Expression Language Elements" section in the VS2005 help, but with no joy. It seems to work though.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[A-Z-[CIKMOV]]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Fairly self-explanatory hopefully, with this particular example matching any one of twenty capital letters. If it is actually documented somewhere, please do point me at it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-114080138054635949?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/114080138054635949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=114080138054635949' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114080138054635949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114080138054635949'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/02/undocumented-regular-expression.html' title='Undocumented regular expression pattern'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-114072491515838845</id><published>2006-02-23T19:39:00.000Z</published><updated>2006-05-04T13:27:23.723+01:00</updated><title type='text'>Multiple keys with KeyedCollection</title><content type='html'>I'm currently dealing with some objects that have two different unique identifiers. One is a public, user-friendly identifier, and the other is an internal, essentially meaningless one. Meaningless, that is, other than the fact that I can ensure that it stays the same for all time, as opposed to the one that users can see, which therefore will no doubt need to be altered 30 times as random punter X changes their mind yet again.&lt;br /&gt;&lt;br /&gt;As a result I wanted a collection where it's possible to grab an item quickly and easily using either of the identifiers. Deriving from &lt;span style="font-family:courier new;"&gt;KeyedCollection&amp;lt;TKey, TItem&amp;gt;&lt;/span&gt; does the job nicely for a single key, so I thought I'd extend that a bit farther and come up with my own cunningly named &lt;span style="font-family:courier new;"&gt;DoubleKeyedCollection&amp;lt;TKey, TSecondKey, TItem&amp;gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;To my shame, I've not even tested this code before posting it up here as it's already long past the end of the day, although it does compile, which is always encouraging if nothing else. I'm not hugely fond of the choice of &lt;span style="font-family:courier new;"&gt;GetItem()&lt;/span&gt; as a method name as it's a bit ambiguous, especially if your two keys are of the same type. &lt;span style="font-family:courier new;"&gt;GetItemBySecondKey()&lt;/span&gt; seemed a bit meaningless to an end client using a class derived from &lt;span style="font-family:courier new;"&gt;DoubleKeyedCollection&lt;/span&gt; though. Any thoughts on the subject are welcome (as is notification of any blatant errors that I've managed to completely overlook).&lt;br /&gt;&lt;br /&gt;As an aside, I think I'll be examining the possibilities of changing the layout of this page. The narrow column doesn't exactly lend itself to code listings. I've done what I can to make it readable. EDIT: Template now changed - not as pretty imho, but makes the code a lot easier to read!&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:white;border:solid 1px black;padding:5px;font-family:lucida console;courier new;font-size:85%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;namespace&lt;/span&gt; Diuturnal.Utility {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;[&lt;span style="color: rgb(51, 153, 153);"&gt;Serializable&lt;/span&gt;]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;public abstract class&lt;/span&gt; &lt;span style="color: rgb(51, 153, 153);"&gt;DoubleKeyedCollection&lt;/span&gt;&amp;lt;TKey, TSecondKey, TItem&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: &lt;span style="color: rgb(51, 153, 153);"&gt;KeyedCollection&lt;/span&gt;&amp;lt;TKey, TItem&amp;gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(51, 153, 153);"&gt;Dictionary&lt;/span&gt;&amp;lt;TSecondKey, TKey&amp;gt; _secondKeyIndex =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(51, 153, 153);"&gt;Dictionary&lt;/span&gt;&amp;lt;TSecondKey, TKey&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;public&lt;/span&gt; TItem GetItem(TSecondKey secondKey) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;return this&lt;/span&gt;[_secondKeyIndex[secondKey]];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;protected abstract&lt;/span&gt; TSecondKey GetSecondKeyForItem(TItem item);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;protected override void&lt;/span&gt; InsertItem(&lt;span style="color: rgb(51, 51, 255);"&gt;int&lt;/span&gt; index, TItem item) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;base&lt;/span&gt;.InsertItem(index, item);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddSecondKeyIndex(&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;.GetSecondKeyForItem(item),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;.GetKeyForItem(item));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;protected override void&lt;/span&gt; RemoveItem(&lt;span style="color: rgb(51, 51, 255);"&gt;int&lt;/span&gt; index) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RemoveSecondKeyIndex(&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;.GetSecondKeyForItem(&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;[index]));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;base&lt;/span&gt;.RemoveItem(index);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;protected override void&lt;/span&gt; SetItem(&lt;span style="color: rgb(51, 51, 255);"&gt;int&lt;/span&gt; index, TItem item) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RemoveSecondKeyIndex(&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;.GetSecondKeyForItem(&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;[index]));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;base&lt;/span&gt;.SetItem(index, item);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddSecondKeyIndex(&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;.GetSecondKeyForItem(item),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;this&lt;/span&gt;.GetKeyForItem(item));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;protected override void&lt;/span&gt; ClearItems() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;base&lt;/span&gt;.ClearItems();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_secondKeyIndex.Clear();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;private void&lt;/span&gt; AddSecondKeyIndex(TSecondKey secondKey, TKey key) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_secondKeyIndex.Add(secondKey, key);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;private void&lt;/span&gt; RemoveSecondKeyIndex(TSecondKey secondKey) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_secondKeyIndex.Remove(secondKey);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-114072491515838845?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/114072491515838845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=114072491515838845' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114072491515838845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/114072491515838845'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/02/multiple-keys-with-keyedcollection.html' title='Multiple keys with KeyedCollection'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113951697666186056</id><published>2006-02-09T20:19:00.000Z</published><updated>2006-05-04T13:25:47.920+01:00</updated><title type='text'>Multiple search patterns with DirectoryInfo.GetFiles()</title><content type='html'>Another visit to Google today showed various requests about how to specify more than one pattern to search for when grabbing the files from a directory, so for example, get all the .mp3 and .wma files in one call.&lt;br /&gt;&lt;br /&gt;As far as I can see, you can only specify one pattern at a time (unless there's something new in 2.0 that I've missed) so I thought this was a good candidate for a simple wrapper. The code below should be fairly easy to modify if you have any specific requirements in your situation.&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:white;border:solid 1px black;padding:5px;font-family:lucida console,courier new;font-size:85%;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;namespace&lt;/span&gt; Diuturnal.Utility {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;public class&lt;/span&gt; &lt;span style="color: rgb(51, 153, 153);"&gt;DirectoryHelper&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;public static&lt;/span&gt; &lt;span style="color: rgb(51, 153, 153);"&gt;FileInfo&lt;/span&gt;[] GetFiles(&lt;span style="color: rgb(51, 153, 153);"&gt;DirectoryInfo&lt;/span&gt; directory,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;params string&lt;/span&gt;[] searchPatterns)&lt;/span&gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 153, 153);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(51, 153, 153);"&gt;FileInfo&lt;/span&gt;&amp;gt; allFiles = &lt;span style="color: rgb(51, 51, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(51, 153, 153);"&gt;List&lt;/span&gt;&lt;&lt;span style="color: rgb(51, 153, 153);"&gt;FileInfo&lt;/span&gt;&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(51, 51, 255);"&gt;string&lt;/span&gt; pattern &lt;span style="color: rgb(51, 51, 255);"&gt;in&lt;/span&gt; searchPatterns)&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;allFiles.AddRange(directory.GetFiles(pattern));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;allFiles.Sort(&lt;span style="color: rgb(51, 51, 255);"&gt;delegate&lt;/span&gt;(&lt;span style="color: rgb(51, 153, 153);"&gt;FileInfo&lt;/span&gt; x, &lt;span style="color: rgb(51, 153, 153);"&gt;FileInfo&lt;/span&gt; y)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;span style="color: rgb(51, 51, 255);"&gt;return&lt;/span&gt; x.Name.CompareTo(y.Name); });&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(51, 51, 255);"&gt;return&lt;/span&gt; allFiles.ToArray();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113951697666186056?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113951697666186056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113951697666186056' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113951697666186056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113951697666186056'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/02/multiple-search-patterns-with.html' title='Multiple search patterns with DirectoryInfo.GetFiles()'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113950518201065044</id><published>2006-02-09T17:09:00.000Z</published><updated>2006-02-09T17:13:02.023Z</updated><title type='text'>FolderBrowserDialog.ShowNewFolderButton</title><content type='html'>A quick Google will tell you that this has been discussed plenty of times before, but seeing as I stumbled across it of my own accord today, I thought I'd give it a mention.&lt;br /&gt;&lt;br /&gt;Set the property (the title of this post) to false, then display the dialog on a Windows 2000 machine. Whoops, the "New Folder" button is still there. Oh well.&lt;br /&gt;&lt;br /&gt;Apparently it works on Windows XP - I guess you just have to live with it if you're running Win2k.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113950518201065044?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113950518201065044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113950518201065044' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113950518201065044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113950518201065044'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/02/folderbrowserdialogshownewfolderbutton.html' title='FolderBrowserDialog.ShowNewFolderButton'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113787882837533372</id><published>2006-01-21T21:19:00.000Z</published><updated>2006-01-21T21:29:03.733Z</updated><title type='text'>Deploying to a Windows Mobile device</title><content type='html'>A few months ago I got myself a Dell Axim X50v, convincing myself that it was a "good investment" as I'd be able to look into developing for the Pocket PC. In time-honoured fashion, I've never actually managed to get past a quick "Hello World" program on it, although I did think it was pretty cool the way you could just hit F5 in Visual Studio and up came the app on my PDA.&lt;br /&gt;&lt;br /&gt;Anyway, I just decided I'd give it another bash with Visual Studio 2005 (Last time I tried I was using 2003) and upon hitting F5 I got the less than useful message "The configuration data for this product is corrupt. Contact your support personnel". Fortunately, Google is here to save the day again, and I found a post on a message board somewhere saying to close down Visual Studio, delete the directory C:\Documents and Settings\&amp;lt;localuser&amp;gt;\Local Settings\Application Data\Microsoft\CoreCon, and then restart and try again.&lt;br /&gt;&lt;br /&gt;Did the trick for me, and I hope it works for you too if you find yourself here on a Google search of your own.&lt;br /&gt;&lt;br /&gt;I get the impression that this folder is/was an artifact of an old beta install of VS2005 although I don't know that for certain. If anyone knows for sure where it comes from please do feel free to enlighten me!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113787882837533372?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113787882837533372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113787882837533372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113787882837533372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113787882837533372'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/01/deploying-to-windows-mobile-device.html' title='Deploying to a Windows Mobile device'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113760560650198391</id><published>2006-01-18T17:12:00.000Z</published><updated>2006-01-19T16:41:01.356Z</updated><title type='text'>Serialization and type versions</title><content type='html'>After stating in my previous post that I write messages in en-GB, I go and ruin that by putting "Serialization" in the title of this one. Go figure.&lt;br /&gt;&lt;br /&gt;Another nice addition in .NET 2.0 are five attributes in the &lt;span style="font-family:courier new;"&gt;System.Runtime.Serialization&lt;/span&gt; namespace. These help with telling v2 of a class how to cope when dealing with objects of type v1. The attributes are as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;OnDeserializedAttribute&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;OnDeserializingAttribute&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;OnSerializedAttribute&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;OnSerializingAttribute&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;OptionalFieldAttribute&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Read the docs for usage, but essentially if you mark the new member fields in v2 with &lt;span style="font-family:courier new;"&gt;[OptionalField]&lt;/span&gt; then it doesn't fall over when attempting to deserialize an object of type v1, as it knows that the info might be missing. You can then use a method marked with &lt;span style="font-family:courier new;"&gt;[OnDeserialized]&lt;/span&gt; to do sensible things like set a default value for a missing field for example.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113760560650198391?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113760560650198391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113760560650198391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113760560650198391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113760560650198391'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/01/serialization-and-type-versions.html' title='Serialization and type versions'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113698135139278934</id><published>2006-01-11T12:03:00.000Z</published><updated>2006-01-25T22:19:21.240Z</updated><title type='text'>"Neutral" Resources</title><content type='html'>The system may have a concept of a "neutral language", but in the real world I tend to write my default messages in a concrete language (which for me is en-GB). When it comes to doing localisation, there's no need to then duplicate the effort and create a separate en-GB resources file - simply mark your "neutral" version with what it actually is.&lt;br /&gt;&lt;br /&gt;You can do this with an attribute (in AssemblyInfo.cs), like so:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[assembly: NeutralResourcesLanguage("en-GB")]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;EDIT: Should have guessed this already really, but I've just realised that in VS2005 with its new GUI to edit the AssemblyInfo.cs file, this attribute is a drop down inside the Assembly Information page anyway. Simplicity itself.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113698135139278934?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113698135139278934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113698135139278934' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113698135139278934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113698135139278934'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/01/neutral-resources.html' title='&quot;Neutral&quot; Resources'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113690593172236028</id><published>2006-01-10T15:04:00.000Z</published><updated>2006-01-12T21:02:51.903Z</updated><title type='text'>Null coalescing operator</title><content type='html'>Fancy title to get things going.&lt;br /&gt;&lt;br /&gt;This is one of those things that'll be second nature once I start using it in anger, but until I do that, I'll consistently forget it.&lt;br /&gt;&lt;br /&gt;C# 2.0 introduces nullable types, and the null coalescing operator (??)  is a binary operator that works pretty much the same way as T-SQL's ISNULL() function.&lt;br /&gt;&lt;br /&gt;So for:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;a ?? b&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;think:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ISNULL(a, b)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One small caveat here is that b could of course be a nullable type as well, in which case the result of a ?? b is still a nullable type. If it's not, the result isn't either. See example below (ripped from C# 2.0 spec).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int? x = GetNullableInt();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int? y = GetNullableInt();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int? z = x ?? y;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int i = z ?? -1;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113690593172236028?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113690593172236028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113690593172236028' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113690593172236028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113690593172236028'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/01/null-coalescing-operator.html' title='Null coalescing operator'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20777823.post-113690403270100415</id><published>2006-01-10T14:34:00.000Z</published><updated>2006-01-10T14:40:32.710Z</updated><title type='text'>First post</title><content type='html'>I figured it was probably fairly obligatory to have a "first post" post. So here it is. At this point I have absolutely no idea if I'll continue this blog beyond the initial novelty value length of a day or two.&lt;br /&gt;&lt;br /&gt;Essentially my only motivation for doing this is as a repository for little tidbits of info I find out whilst wading my way through the world of .NET programming, as I've lost count of the number of times I've thought, "I remember reading about how to do that... now if only I could find it..."&lt;br /&gt;&lt;br /&gt;With any luck if I convince myself to dump it in here then I'll be able to find it again later. So if you've got no interest in programming, look elsewhere. I don't feel the need to share with the world what I had for tea last night, who I babysat for at the weekend, or why I'll be choosing gloss rather than matt paint for decorating.&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20777823-113690403270100415?l=kntajus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kntajus.blogspot.com/feeds/113690403270100415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20777823&amp;postID=113690403270100415' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113690403270100415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20777823/posts/default/113690403270100415'/><link rel='alternate' type='text/html' href='http://kntajus.blogspot.com/2006/01/first-post.html' title='First post'/><author><name>Stephen Salt</name><uri>http://www.blogger.com/profile/12125939334750090987</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
