﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Will Asrari ~ Bellingham, WA Web Development (ASP.NET, VB .NET, C#, SQL)</title><link>http://blog.willasrari.com</link><description>Personal blog, code samples, tutorials, and articles about ASP.NET, C#, and SQL!</description><copyright>Copyright (C) 2005-2006</copyright><ttl>5</ttl><item><title>External URLs and Phone Numbers in WP7 WebBrowser Control</title><description>The &lt;a href="http://msdn.microsoft.com/en-us/library/ff431812%28v=vs.92%29.aspx"&gt;Windows Phone 7 WebBrowser&lt;/a&gt; is garbage.&amp;nbsp; F**king horrible. If you want to display basic HTML it's great.&amp;nbsp; If you want to display HTML that users can interact with (i.e. clicking hyperlinks, mailto: links, or dial phone numbers) it's basically useless.&amp;nbsp; Don't even get me started on opacity and background images.&amp;nbsp; In developing a Windows Phone 7 application recently there was a need to link to a mobile-enabled website.  In said website there were pages with phone numbers, email addresses, etc...  A business requirement for the application was to open up the mail client, dial a phone number, or open a hyperlink when a user clicked on these links.&amp;nbsp; No duh right?&amp;nbsp; I thought the WebBrowser would at least be able to parse out links with href and mailto and since it's built for a PHONE it should be smart enough to detect tel.&amp;nbsp; Fail.&lt;br&gt;&lt;br&gt;At this point we had a couple of options (&lt;a href="http://www.pcmag.com/article2/0,2817,2387131,00.asp"&gt;Mango&lt;/a&gt; is NOT an option at this point):&lt;br&gt;&lt;ol&gt;&lt;li&gt;Recreate the external site in XAML with event handlers for the "hyperlinks" which would end up being styled textblock controls&lt;/li&gt;&lt;li&gt;Take a screenshot of the mobile site and place rectangles over the hyperlinks and wire those up to events&lt;/li&gt;&lt;li&gt;Download the HTML from the site asynchronously, parse HTML and find &lt;code&gt;head&lt;/code&gt; or &lt;code&gt;title&lt;/code&gt; tags, inject JavaScript to find and enumerate all &lt;code&gt;a&lt;/code&gt; tags and wire up an &lt;code&gt;onclick&lt;/code&gt; event to raise the &lt;code&gt;ScriptNotify&lt;/code&gt; event [via &lt;code&gt;window.external.Notify&lt;/code&gt;], call the WebBrowser's &lt;code&gt;NavigateToString&lt;/code&gt; method and pass in this newly-constructed HTML, figure out what kind of link was clicked and then fire an appropriate task&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;
Before I talk about which option I chose, take a minute to soak in the absurdity of the aforementioned solutions (FYI - I chose 3).

Take this simple example site here:

&lt;br&gt;&lt;br&gt;&lt;img src="/blog/uploads/webbrowser-sucks-01.png" alt="simple webbrowser example 1"&gt;
&lt;p&gt;And here's the markup (unadulterated)&lt;/p&gt;&lt;p&gt;&lt;img style="width: 530px; height: 366px;" src="/blog/uploads/webbrowser-sucks-02.png" alt="simple webbrowser example 2"&gt;&lt;/p&gt;Simple enough right? You can clearly see that the links are sporting the correct syntax.  Time to start hacking.
&lt;p&gt;The first thing we need to do is add JavaScript to get all of our &lt;code&gt;a&lt;/code&gt; tags. Once we have this we simply need to enumerate and attach an &lt;code&gt;onclick&lt;/code&gt; event.  I'm not a JavaScript expert by any means but think this fairly unobtrusive. This JavaScript is going to remain constant so we should use the &lt;code&gt;const&lt;/code&gt; string:&lt;/p&gt;
&lt;p&gt;&lt;a href="/blog/uploads/webbrowser-sucks-03.png"&gt;&lt;img style="width: 526px; height: 143px;" src="/blog/uploads/webbrowser-sucks-03.png" alt="simple webbrowser example 3"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The next thing we need to do is wire up the WebBrowser control.  The most important part is to enable scripting via the &lt;code&gt;IsScriptEnabled&lt;/code&gt; property. This is set to &lt;code&gt;false&lt;/code&gt; by default and resulted in many f-bombs being dropped until I figured this out. We will also need to wire up the &lt;code&gt;ScriptNotify&lt;/code&gt; event.  This is how the WebBrowser will communicate with our application.&lt;/p&gt;&lt;p&gt;&lt;a href="/blog/uploads/webbrowser-sucks-04.png"&gt;&lt;img style="width: 530px; height: 258px;" src="/blog/uploads/webbrowser-sucks-04.png" alt="simple webbrowser example 4"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;In the &lt;code&gt;LoadedComplete&lt;/code&gt; method we perform an asynchronous request via &lt;code&gt;WebClient&lt;/code&gt; object to get the source HTML from the server. We then create a &lt;code&gt;StringBuilder&lt;/code&gt; instance and insert our JavaScript just before the &lt;code&gt;&amp;lt;/title&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;&lt;p&gt;Now that the &lt;code&gt;ScriptNotify&lt;/code&gt; event is wired up we can set a breakpoint in our code, run the application, and determine which link was clicked when we tap the link.&lt;/p&gt;&lt;p&gt;&lt;img src="/blog/uploads/webbrowser-sucks-05.png" alt="simple webbrowser example 5"&gt;&lt;/p&gt;&lt;p&gt;In the case above, we'll want to launch the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.webbrowsertask%28v=vs.92%29.aspx"&gt;&lt;code&gt;EmailComposeTask&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;img src="/blog/uploads/webbrowser-sucks-06.png" alt="simple webbrowser example 6"&gt;&lt;/p&gt;&lt;p&gt;Running this code in the emulator and we get the following:&lt;/p&gt;&lt;p&gt;&lt;img src="/blog/uploads/webbrowser-sucks-07.png" alt="simple webbrowser example 7"&gt;&lt;/p&gt;&lt;p&gt;I don't have a mail account setup in the emulator (is this possible?) so we see the fail message. But if I did in fact have an email account setup it would display appropriately.  For other scenarios you would use the appropriate phone task.&lt;/p&gt;&lt;p&gt;Easy enough.  This code isn't production-ready by any means.  I just wanted to quickly share with others how to accomplish a task that should be a native experience (IMO). I will clean this up and add logic for things such as detecting if there is actually a &lt;code&gt;title&lt;/code&gt; tag, confirming that a task is about to be shown, cleaning up the &lt;code&gt;ScriptNotify&lt;/code&gt; event handler, etc... This would take about 3 seconds using &lt;a href="http://en.wikipedia.org/wiki/Interface_Builder"&gt;Interface Builder&lt;/a&gt; in Mac OS (iOS development). iOS developers have the luxury of checking boxes for detecting various links in text controls.&lt;/p&gt;&lt;p&gt;Original inspiration: &lt;a href="http://www.ben.geek.nz/2010/07/integrated-links-and-styling-for-windows-phone-7-webbrowser-control/"&gt;Integrated Links and Styling for Windows Phone 7 WebBrowser Control&lt;/a&gt;&lt;/p&gt;
</description><link>http://www.willasrari.com/blog/external-urls-and-phone-numbers-in-wp7-webbrowser-control/000348.aspx</link><pubDate>7/12/2011 1:30:03 AM</pubDate><author>Will Asrari</author></item><item><title>Json.NET and Generic HttpWebRequest Responses FTW</title><description>&lt;p&gt;Working on a &lt;a href="http://www.microsoft.com/windowsphone/en-us/default.aspx?WT.srch=1&amp;amp;WT.mc_id=Search&amp;amp;cmpid=7D846D7D-BB78-41C1-A054-CBD14AACF98D"&gt;Windows Phone 7&lt;/a&gt; mobile app recently, I found myself writing a bunch of similar / redundant code for &lt;code&gt;HttpWebRequest&lt;/code&gt; response handling. By "a bunch" I mean in the neighborhood of 3 methods.... Hello &lt;a href="http://msdn.microsoft.com/en-us/library/ms172192.aspx"&gt;Generics&lt;/a&gt;!!!&lt;/p&gt;&lt;p&gt;If I find myself writing the same handler more than once and the only difference is the type of object I am returning I ALWAYS (at least try to) write a generic method to take care of the heavy lifting.&amp;nbsp; There are a plethora of reasons to use Generics when the opportunity presents itself and I'm not going to start listing them.&amp;nbsp; Those of you that understand .NET Generics will get it.&amp;nbsp; If you are a .NET developer and currently developing applications targeting version 2.0 or greater and aren't familiar with Generics, then I highly suggest you educate yourself: &lt;a href="http://msdn.microsoft.com/en-us/library/ms172192.aspx"&gt;Generics in the .NET Framework&lt;/a&gt;.&lt;br&gt;&lt;br&gt;If you are still with me and are familiar with the &lt;a href="http://msdn.microsoft.com/en-us/library/btdf6a7e%28v=VS.95%29.aspx"&gt;&lt;code&gt;System.Net&lt;/code&gt;&lt;/a&gt; namespace and the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.95%29.aspx"&gt;&lt;code&gt;HttpWebRequest&lt;/code&gt;&lt;/a&gt; class (as it pertains to Silverlight and/or Windows Phone 7), I'd like to share the following response handler for dealing with Asynchronous requests:&lt;/p&gt;&lt;p&gt;&lt;code&gt;private static T ProcessFamiliarRequestResponse&amp;lt;T&amp;gt;(IAsyncResult asyncResult)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebResponse httpWebResponse = (HttpWebResponse)request.EndGetResponse(asyncResult);&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return JsonWorker.TooEasyToDeserializeJsonObject&amp;lt;T&amp;gt;(streamReader.ReadToEnd());&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/code&gt;&lt;/p&gt;&lt;p&gt;If this doesn't make sense to you I highly suggest reading up on &lt;a href="http://blogs.msdn.com/b/silverlight_sdk/archive/2008/04/01/using-webclient-and-httpwebrequest.aspx"&gt;WebClient&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/b/silverlight_sdk/archive/2008/04/01/using-webclient-and-httpwebrequest.aspx"&gt;HttpWebRequest&lt;/a&gt; usage.&amp;nbsp; If you are familiar, I hope you can appreciate that this is one point of entry into handling an infinite number of requests (within reason).&lt;/p&gt;&lt;p&gt;It gets cleaner: Enter &lt;a href="http://json.codeplex.com/"&gt;Json.NET&lt;/a&gt;.&amp;nbsp; Personally, I like to create clean POCO's to return data to the consumer.&amp;nbsp; I have seen way too many examples creating objects that conform EXACTLY to the Json format returned from any given request.&amp;nbsp; For instance:&lt;/p&gt;&lt;p&gt;&lt;code&gt;public class Employee&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string employee_first_name { get; set; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string employee_last_name { get; set; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string employee_job_description { get; set; }&lt;br&gt;}&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Gross (imo).&amp;nbsp; .NET is so much better than this.&amp;nbsp; I take pride in the code that I deliver and personally believe the following class is much cleaner (and not to mention, conforms to .NET naming conventions):&lt;/p&gt;&lt;p&gt;&lt;code&gt;public class Employee&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [JsonProperty("employee_first_name")]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string FirstName { get; set; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [JsonProperty("employee_last_name")]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string LastName { get; set; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [JsonProperty("employee_job_description")]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string JobDescription { get; set; }&lt;br&gt;}&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;This way you can map your neatly-defined POCO properties to their disgusting origins.&amp;nbsp; The following generic method for deserializing your Json results works fairly well (pre-supposing you decorated your POCO(s) with the &lt;a href="http://james.newtonking.com/projects/json/help/html/T_Newtonsoft_Json_Serialization_JsonProperty.htm"&gt;&lt;code&gt;JsonProperty&lt;/code&gt;&lt;/a&gt; attribute OR left it repulsive and/or primitive):&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;public static class JsonWorker&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static T DeserializeJsonObject&amp;lt;T&amp;gt;(string result)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return JsonConvert.DeserializeObject&amp;lt;T&amp;gt;(result);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/code&gt;&lt;/p&gt;&lt;p&gt;If you want to take it a step further, you could add the following method to your &lt;code&gt;JsonWorker&lt;/code&gt; class to serialize your objects. Think storing application state in IsolatedStorage or updating your light-weight, client-side database (via &lt;a href="http://sterling.codeplex.com/"&gt;Sterling&lt;/a&gt; (which is AWESOME!!!)):&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;public static string WayEasierToSerializeObjectToJson(object randomPOCO)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return JsonConvert.SerializeObject(randomPOCO);&lt;br&gt;}&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Easy.&lt;/p&gt;</description><link>http://www.willasrari.com/blog/jsonnet-and-generic-httpwebrequest-responses-ftw/000346.aspx</link><pubDate>5/25/2011 1:33:10 AM</pubDate><author>Will Asrari</author></item><item><title>Debug a Windows Phone 7 Application After a Tombstone</title><description>&lt;p&gt;In debugging a Windows Phone 7 issue related to application state and tombstoning recently, I found that the Visual Studio debugger stops after the application comes back from a tombstone (press the Windows putton on Windows Phone 7 emulator, then press device back button to reactivate the application).&amp;nbsp; A quick Google search and I ran across a little &lt;a href="http://wildermuth.com/2010/08/19/Debugging_Tombstoning_in_Windows_Phone_7"&gt;gem&lt;/a&gt; on &lt;a href="http://wildermuth.com"&gt;Shawn Wildermuth&lt;/a&gt;'s blog.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Solution:&amp;nbsp; Press F5 again while the emulator is displaying the "Resuming...." progress indicator.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Easy.&lt;/p&gt;</description><link>http://www.willasrari.com/blog/debug-a-windows-phone-7-application-after-a-tombstone/000345.aspx</link><pubDate>11/18/2010 12:59:55 AM</pubDate><author>Will Asrari</author></item><item><title>Set Silverlight Startup Page</title><description>&lt;p&gt;In sandboxing Windows Phone 7 recently I came across the need to change my startup page.&amp;nbsp; The reasoning for this is simple: I have a core of the work completed and I want to sandbox a data call before I implement in the actual application.&amp;nbsp; With conventional web projects this is as easy as right-clicking the file you want to and click 'Set As Start Page'. With the Windows Phone 7 SDK this luxury does not exist.&lt;/p&gt;&lt;p&gt;There is however a way to accomplish this with a little bit of code.&amp;nbsp; Simply open up your projects App.xaml.cs and implement an &lt;code&gt;Application_Startup&lt;/code&gt; method.&lt;/p&gt;&lt;p&gt;&lt;code&gt;private void Application_Startup(object sender, StartupEventArgs e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RootVisual = new SandboxPage();&lt;br&gt;}&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;SandboxPage&lt;/code&gt; is the name of my XAML page in this example. Here we simply set the &lt;code&gt;RootVisual&lt;/code&gt; to an instance of our new page.&lt;/p&gt;&lt;p&gt;The second piece to this is registering this startup method in the &lt;code&gt;App&lt;/code&gt; constructor a la:&lt;/p&gt;&lt;p&gt;&lt;code&gt;public App()&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Startup += Application_Startup;&lt;br&gt;}&lt;/code&gt;&lt;/p&gt;&lt;p&gt;This doesn't necessarily apply to Windows Phone 7.&amp;nbsp; General Silverlight.&lt;/p&gt;&lt;p&gt;Easy.&lt;br&gt;&lt;/p&gt;</description><link>http://www.willasrari.com/blog/set-silverlight-startup-page/000343.aspx</link><pubDate>8/6/2010 3:47:11 PM</pubDate><author>Will Asrari</author></item><item><title>Hello Windows Phone</title><description>&lt;p&gt;Today the Community Technology Preview release of Visual Studio 2010 Express for Windows Phone 7 was released. For those not in the know, this release provides 100% compatibility with the final version of Visual Studio 2010.&lt;/p&gt;&lt;p&gt;You can get it here: &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=cabcd5ed-7dfc-4731-9d7e-3220603cad14"&gt;Visual Studio 2010 Express for Windows Phone 7&lt;/a&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://i43.tinypic.com/wrxbgi.png"&gt;&lt;/p&gt;&lt;p&gt;I have been interested in and writing XNA for a couple of months now and will start posting more regularly thanks to this new addition.&lt;/p&gt;&lt;p&gt;Stay tuned!&lt;/p&gt;</description><link>http://www.willasrari.com/blog/hello-windows-phone/000342.aspx</link><pubDate>5/6/2010 7:13:04 PM</pubDate><author>Will Asrari</author></item><item><title>Dynamically Insert Language ISO Code in Sitecore Url</title><description>&lt;p&gt;In working with localizing a &lt;a href="http://www.sitecore.net"&gt;Sitecore&lt;/a&gt; CMS solution recently I came across an interesting requirement: analytics (SEO optimization by region).&amp;nbsp; I was handling Sitecore localization by adding supported languages and creating localized versions of each content item.&amp;nbsp; The wrinkle was that I needed to now add a language prefix to all the urls on the site so they could get indexed appropriately for each region.&amp;nbsp; To make it even more complicated, I had to deal with hard-coded urls that weren't driven by the CMS.&amp;nbsp; I thought I was going to have to create multiple sites within Sitecore for each language, duplicate content, etc...&amp;nbsp; It turns out that it was much easier than this.&lt;/p&gt;&lt;p&gt;In a Sitecore web.config you'll find a &lt;code&gt;linkManager&lt;/code&gt; section.  This will handle much of the heavy lifting for you. There is one setting that you need to pay attention to (2 if you aren't using IIS 7).&lt;/p&gt;
&lt;p&gt;The first (and most important) is the &lt;code&gt;languageEmbedding&lt;/code&gt; setting. In a site that is in one language you should set to "never". A site that may have one or two localized pages here and there set to "asNeeded". In my case, a full-blown localization effort, this should be set to "always".&lt;/p&gt;&lt;p&gt;If you aren't using IIS 7 you will need to set the &lt;code&gt;&lt;/code&gt; setting for &lt;code&gt;addAspxExtension&lt;/code&gt; to "true".&lt;/p&gt;&lt;p&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;linkManager defaultProvider="sitecore"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;providers&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;clear /&amp;gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addAspxExtension="true"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alwaysIncludeServerUrl="false"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; encodeNames="true"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; languageEmbedding="always"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; languageLocation="filePath"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shortenUrls="true"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useDisplayName="false" /&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/providers&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/linkManager&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Sitecore CMS will now take care of the url rewriting!&amp;nbsp; Easy.&lt;/p&gt;&lt;p&gt;For those you like me that have pre-defined navigation requirements (i.e. not driven 100% by the CMS) there is one more step to take to accomplish url prefixing.&amp;nbsp; Take a link such as:&lt;/p&gt;&lt;p&gt;&lt;code&gt;&amp;lt;a href="/Foo.aspx"&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;To get a url that looks like http://www.foo.com/de-DE/foo.aspx you simply need to write a little bit of "yellow code".&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&amp;lt;a href="/&amp;lt;%= Sitecore.Context.Language %&amp;gt;/foo.aspx"&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Easy.&lt;/p&gt;</description><link>http://www.willasrari.com/blog/dynamically-insert-language-iso-code-in-sitecore-url/000341.aspx</link><pubDate>4/29/2010 11:55:39 AM</pubDate><author>Will Asrari</author></item><item><title>Problem Deploying MVC Applications on IIS 5.1 or IIS 6?</title><description>&lt;p&gt;I know what you are thinking, "Who uses IIS 5.1 or IIS 6 these days?"&amp;nbsp; Believe it or not, some environments still use these and I had been pulling my hair out trying to deploy an MVC application to an IIS 5.1 server.  The application works in production and wasn't working locally.  Nothing had changed aside from some minor View refactoring. A couple of hours later I thought back to an Ektron project that required URL-rerouting and then it dawned on me: "IIS is checking to make sure that the file exists".&lt;/p&gt;&lt;p&gt;I opened up IIS, drilled down to my application, and followed these steps:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Right-click application (or virtual directory)&lt;/li&gt;&lt;li&gt;Click 'Properties'&lt;/li&gt;&lt;li&gt;Click 'Home Directory' if application ('Virtual Directory' if virtual directory)&lt;/li&gt;&lt;li&gt;Click 'Configuration' button&lt;/li&gt;&lt;li&gt;Click 'Add' button&lt;/li&gt;&lt;li&gt;Executable: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll&lt;/li&gt;&lt;li&gt;Extension: .*&lt;/li&gt;&lt;li&gt;Check 'All Verbs' if it isn't already (it should be)&lt;/li&gt;&lt;li&gt;Uncheck 'Check file exists'&lt;/li&gt;&lt;li&gt;Click 'OK'&lt;/li&gt;&lt;li&gt;Click 'Apply'&lt;/li&gt;&lt;li&gt;Click 'OK'&lt;/li&gt;&lt;/ol&gt;Dear Diary. Jackpot.&lt;br&gt;</description><link>http://www.willasrari.com/blog/problem-deploying-mvc-applications-on-iis-51-or-iis-6/000340.aspx</link><pubDate>12/10/2009 3:15:26 PM</pubDate><author>Will Asrari</author></item><item><title>jQuery Data Method is the Business</title><description>&lt;p&gt;&amp;lt;3 &lt;a href="http://docs.jquery.com/Internals/jQuery.data"&gt;this&lt;/a&gt; little &lt;a href="http://www.jquery.com"&gt;jQuery&lt;/a&gt; gem&lt;br&gt;&lt;/p&gt;
&lt;code&gt;$(document).ready(function() {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $('#button').data('Data', { Message: 'sup foo?', Email: 'asdf@asdf.com' });&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $('#button').click(function() {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var data = $(this).data('Data');&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(data.Message + '\n' + data.Email);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br&gt;});&lt;br&gt;
&lt;br&gt;
&amp;lt;input type="button" id="button" value="clickie" /&amp;gt;&lt;br&gt;&lt;/code&gt;&lt;p&gt;&lt;img src="http://i49.tinypic.com/2pq16dz.png" alt="jQuery data() method result"&gt;&lt;/p&gt;&lt;p&gt;Easy.&lt;/p&gt;</description><link>http://www.willasrari.com/blog/jquery-data-method-is-the-business/000336.aspx</link><pubDate>11/5/2009 2:37:09 PM</pubDate><author>Will Asrari</author></item><item><title>Generic jQuery Function to Remove CSS Classes</title><description>&lt;P&gt;I've been using a lot of &lt;A href="http://jquery.com/"&gt;jQuery&lt;/A&gt; lately in a new project and am falling in love with it!&amp;nbsp; It is a wonder why I have never used it before but am glad I was kind of forced to learn it ;)&lt;/P&gt;
&lt;P&gt;As with anything new there is a bit of a learning curve.&amp;nbsp; The application I am working on boasts a large number of tabs for different sections of the site.&amp;nbsp; One of the requirements is to toggle the "active" tab via CSS class.&amp;nbsp; Easy right?&amp;nbsp; This was easy to do in vanilla JavaScript so it should be super-easy to do with jQuery.&amp;nbsp; It is!&lt;/P&gt;&lt;CODE&gt;&lt;B&gt;
&lt;P&gt;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'#FooItem1'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).removeClass(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'active'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;);&lt;BR&gt;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'#FooItem2'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).removeClass(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'active'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;);&lt;BR&gt;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'#FooItem3'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).removeClass(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'active'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;);&lt;BR&gt;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'#FooItem4'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).removeClass(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'active'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;);&lt;BR&gt;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'#FooItem5'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).removeClass(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;'active'&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;);&lt;/P&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;That works great but there is one caveat: adding new tabs.&amp;nbsp; If the requirements of the UI changed and we were to have to add a new tab (or 6 more) then we would have to not only change the view (or in this case partial view ;) ) but also the JavaScript functions dealing with these tabs.&amp;nbsp; Since all of our tabs are &lt;CODE&gt;UL&lt;/CODE&gt; with stylized &lt;CODE&gt;LI&lt;/CODE&gt;'s containing anchor tags I decided to create something like this:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;function&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt; RemoveActiveClassFromListItemControlByID(controlID) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"#"&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt; + controlID).children().each(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;function&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;() {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).children(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"a"&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).removeClass(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"active"&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;);});&lt;BR&gt;}&lt;/P&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Now this isn't &lt;EM&gt;that&lt;/EM&gt; generic since I have the "a" and "active" strings hard-coded.&amp;nbsp; In this case it works for us since all the tabs are the same format and all we really need is the id of the control.&amp;nbsp; This little function will enumerate the children of the control (in this case all &lt;CODE&gt;LI&lt;/CODE&gt;'s and then enumerate the &lt;CODE&gt;A&lt;/CODE&gt; children and remove the &lt;CODE&gt;active&lt;/CODE&gt; css class.&amp;nbsp; Simple.&amp;nbsp; To extend this to be even more generic you could do the following:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;function&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt; RemoveClassNamesFromChildElementByControlID(controlID, childElement, className) {&lt;BR&gt;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"#"&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt; + controlID).children().each(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;function&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;() {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;).children(childElement).removeClass(className);});&lt;BR&gt;}&lt;/P&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Here's an example of how you could use the function above.&amp;nbsp; Let's say that you want to enumerate all children in a &lt;CODE&gt;OL&lt;/CODE&gt; with an id of "fooList". Each children has a &lt;CODE&gt;span&lt;/CODE&gt; tag with a css class of &lt;CODE&gt;BAR&lt;/CODE&gt; and you want to reset all of them when a user clicks on a hyperlink.&amp;nbsp; This would be extremely simple:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;a&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;href&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;="javascript:(RemoveClassNamesFromChildElementByControlID('fooList', 'span', 'BAR'));"&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;CLICK HERE&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;a&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Easy.&amp;nbsp; I'm really starting to love this jQuery business.&lt;/P&gt;
&lt;P&gt;jQuery + MVC = love&lt;/P&gt;</description><link>http://www.willasrari.com/blog/generic-jquery-function-to-remove-css-classes/000334.aspx</link><pubDate>6/10/2009 3:10:42 PM</pubDate><author>Will Asrari</author></item><item><title>SQL Server 2008 Save Not Permitted Dialog Box</title><description>&lt;P&gt;I was creating some tables this evening in a SQL Server 2008 database this evening so that I could sandbox some MVC functionality for a current project.&amp;nbsp; I had designed the tables according to the tutorial only to find out that this wasn't the case.&amp;nbsp; I'll just log back in to SQL and make the necessary changes.&amp;nbsp; Easy.&lt;/P&gt;
&lt;P&gt;When I added the missing column I went ahead and reordered to match the same order of the tutorial because, well; I am a little OCD at times.&amp;nbsp; I remember doing this in the past pre-SQL 2008 with no trouble.&amp;nbsp; This time I was hit with this:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://i41.tinypic.com/vqtwn5.png"&gt;&lt;/P&gt;
&lt;P&gt;Weird.&amp;nbsp; Again, I had never seen this before so I was a bit surprised.&lt;/P&gt;
&lt;P&gt;According to &lt;A href="http://msdn.microsoft.com/en-us/library/bb895146.aspx"&gt;SQL Server 2008 Books Online&lt;/A&gt; this can be caused by any of the following:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Adding a new column to the middle of the table 
&lt;LI&gt;Dropping a column 
&lt;LI&gt;Changing column nullability 
&lt;LI&gt;Changing the order of the columns 
&lt;LI&gt;Changing the data type of a column&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Really?&amp;nbsp; These all seem like fairly common tasks when working within a database.&amp;nbsp; As odd as this may seem (maybe there is a good reason for this?), there is a very easy fix.&lt;/P&gt;
&lt;P&gt;From the &lt;STRONG&gt;Tools&lt;/STRONG&gt; menu click on &lt;STRONG&gt;Options&lt;/STRONG&gt;, expand &lt;STRONG&gt;Designers&lt;/STRONG&gt;, click on &lt;STRONG&gt;Table and Database Designers&lt;/STRONG&gt;.&amp;nbsp; Select or clear the &lt;STRONG&gt;Prevent saving changes that require table re-creation&lt;/STRONG&gt; option.&lt;/P&gt;
&lt;P&gt;Much better.&amp;nbsp; Back to work.&lt;/P&gt;</description><link>http://www.willasrari.com/blog/sql-server-2008-save-not-permitted-dialog-box/000333.aspx</link><pubDate>6/3/2009 12:49:46 AM</pubDate><author>Will Asrari</author></item><item><title>SQL 2008 and The Setup Failed to Read IIsMimeMap Table</title><description>&lt;P&gt;Decided to install SQL 2008 recently because of it being 2009 and all.&amp;nbsp; What an adventure.&amp;nbsp; Although not near as bad as upgrading from Vista Home Premium to Vista Ultimate, it sucked pretty bad.&lt;/P&gt;
&lt;P&gt;I downloaded the 120-day trial Developer Edition as a self-extracting executable because I didn't feel like burning a DVD / using Daemon Toolz.&amp;nbsp; The download was the smoothest part of this whole deal.&lt;/P&gt;
&lt;P&gt;From the installer screen I chose the Upgrade from SQL 2000 / 2005 option because I have SQL 2005 Developer Edition installed so this made the most sense.&amp;nbsp; Miserable fail.&amp;nbsp; I kept erroring out when trying to install SQL Reporting Services.&amp;nbsp; The exact error(s) escape me but I remember it having something to do with authentication and the report service.&amp;nbsp; Naturally I thought to manually stop and start the service to see if there was any issue.&amp;nbsp; Good thing because manually starting the service failed.&amp;nbsp; It then dawned on me that between the time I had initially installed SQL 2005 and that very instant I had changed my Windows password.&amp;nbsp; Right-click, 'Properties' and changed it to my current password, restart the service: SUCCESS!&lt;/P&gt;
&lt;P&gt;Now let's try upgrading again: FAIL!&lt;/P&gt;
&lt;P&gt;After hitting the Google fairly hard I read a couple of blog entries detailing how uninstalling SQL Server 2005 entirely from the Control Panel would remedy the situation.&amp;nbsp; I tried this and received the following error when attempting to uninstall SQL 2005 Reporting Services:&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Failed to read IIsMimeMap table 01" src="http://i43.tinypic.com/205vxx5.png"&gt;&lt;/P&gt;
&lt;P&gt;Awesome.&amp;nbsp; Have no idea what this means so I searched Google for it.&amp;nbsp; Apparently no one else does either.&amp;nbsp; There were tons of suggestions as to how to go about remedy'ing this so I tried a couple.&amp;nbsp; These solutions ranged from reconfiguring Reporting Services to uninstalling and reinstalling IIS7.&amp;nbsp; I opted to try and reconfigure Reporting Services only to find that the configuration tools no longer existed on my machine seeing as how that was successfully uninstalled before receiving the error message above.&amp;nbsp; I then tried to uninstall again and received this error message.&lt;/P&gt;&lt;IMG alt="Failed to read IIsMimeMap table 02" src="http://i39.tinypic.com/j82j6d.png"&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Same error, different error code. Weird.&lt;/P&gt;
&lt;P&gt;The final solution was to install each component of SQL 2005 one-by-one from Control Panel.&amp;nbsp; As crazy as that sounds it actually ended up being successful.&lt;/P&gt;
&lt;P&gt;So, if you are getting these error messages try uninstalling each and every SQL 2005 component one-by-one and then do a clean install of SQL 2008.&amp;nbsp; It worked for me.&lt;/P&gt;</description><link>http://www.willasrari.com/blog/sql-2008-and-the-setup-failed-to-read-iismimemap-table/000332.aspx</link><pubDate>1/6/2009 1:27:40 PM</pubDate><author>Will Asrari</author></item><item><title>LAMP Developer Needed</title><description>&lt;P&gt;Checked an e-mail account that has apparently been exluded from my main Send/Receive group in Outlook today and found this e-mail in the Junk E-mail folder.&lt;/P&gt;
&lt;P&gt;Maybe I should use this to setup a rule...&lt;/P&gt;
&lt;P&gt;;)&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="LAMP Developer Needed" src="http://i36.tinypic.com/35asttu.png"&gt;&lt;/P&gt;
&lt;P&gt;I have learned a bunch of exciting things over the past couple of months but unfortunately it's proprietary and I can't blog about it! &lt;/P&gt;
&lt;P&gt;I was never one to blog about where I work or what projects I have been working or else I'd have a ton of new entries.&lt;/P&gt;</description><link>http://www.willasrari.com/blog/lamp-developer-needed/000331.aspx</link><pubDate>12/11/2008 9:14:08 PM</pubDate><author>Will Asrari</author></item><item><title>Microsoft Office Interop Outlook &amp; C# For Outlook Searches</title><description>&lt;P&gt;I had a need yesterday to query a bunch of Outlook e-mails: 44,743 to be exact.&amp;nbsp; This was the result of a clients mailing list account being setup incorrectly and we just found out about it!&amp;nbsp; An e-mail account was setup strictly for the mailing list and it was never properly setup as an Outlook account locally.&amp;nbsp; No big deal.&amp;nbsp; When the hosting provider contacted us to clean it up I noticed that there were a BUNCH of bad e-mail addresses (Return to sender, bad account, etc...).&amp;nbsp; At first I started to click on individual e-mails, copy the bad e-mail address to a .txt file, then search that folder for the same e-mail address and delete the results.&amp;nbsp; That takes FOOOOORRREEEEVVVVEEEEERRRRRRR.&amp;nbsp; Then I realized I could dork around with Outlook via a C# console application and harvest the e-mails and output them in a sorted Excel spreadsheet.&lt;/P&gt;
&lt;P&gt;Enter &lt;CODE&gt;Microsoft.Office.Core&lt;/CODE&gt; and &lt;CODE&gt;Microsoft.Office.Interop.Outlook&lt;/CODE&gt; namespaces.&amp;nbsp;I decided&amp;nbsp;it would be best to create a little&amp;nbsp;C# console application utilizing these namespaces to search the e-mail, write a&amp;nbsp;little regular expression&amp;nbsp;pattern (by write I mean copy &amp;amp; paste&amp;nbsp;one from the interwebs)&amp;nbsp;to parse out e-mail addresses, and add e-mail addresses that didn't have the host name or the reply e-mail account in it to a &lt;CODE&gt;List&amp;lt;string&amp;gt;&lt;/CODE&gt; (if it didn't already contain it!).&amp;nbsp; It was pretty easy.&lt;/P&gt;
&lt;P&gt;First:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;using&lt;/FONT&gt; Outlook = Microsoft.Office.Interop.Outlook;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt; Microsoft.Office.Interop.Outlook;&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;I'm not going to bore you with the entire application unless you really want it.&amp;nbsp; I'll just get you to the point where you can start to do &lt;EM&gt;stuff&lt;/EM&gt; with your e-mails.&lt;/P&gt;
&lt;P&gt;Now you need to instantiate your Outlook object.&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;Outlook.&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;Application&lt;/FONT&gt; application = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;Application&lt;/FONT&gt;();&lt;BR&gt;Outlook.&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;NameSpace&lt;/FONT&gt; nameSpace = application.GetNamespace(&lt;/FONT&gt;&lt;FONT color=#a31515&gt;"MAPI"&lt;/FONT&gt;);&lt;BR&gt;Outlook.&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;MAPIFolder&lt;/FONT&gt; mapiFolder = nameSpace.GetDefaultFolder(&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;OlDefaultFolders&lt;/FONT&gt;.olFolderJunk);&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;It might be worth mentioning the olFolderJunk business you see there.&amp;nbsp; In the interest of time I didn't want to mess around with trying to navigate to the folder that I actually stored these e-mails in since I have a bunch of subfolders in Outlook due to using multiple accounts and a handful of rules and what-not.&amp;nbsp; So in the interest of time I moved all the e-mails to the junk folder since I could easily access it.&amp;nbsp; I think the correct syntax would be something like:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;nameSpace.Folders[&lt;FONT color=#a52a2a&gt;"FOLDER"&lt;/FONT&gt;].Folders[&lt;FONT color=#a52a2a&gt;"SUB"&lt;/FONT&gt;].Folders[&lt;FONT color=#a52a2a&gt;"YOU_GET_IT"&lt;/FONT&gt;];&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Moving on.&amp;nbsp; Once you finally get access to your designated folder you need to start being able to do stuff with the items in that folder.&amp;nbsp; It's as easy as enumerating the, you guessed it; &lt;CODE&gt;MailItem&lt;/CODE&gt; objects a la:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;foreach&lt;/FONT&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;MailItem&lt;/FONT&gt; mailItem &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; mapiFolder.Items)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// do stuff&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Easy.&amp;nbsp; The properties are fairly braindead as well.&amp;nbsp; &lt;A href="http://msdn.microsoft.com/en-us/library/bb176688.aspx"&gt;MailItem Object Members&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Have fun.&amp;nbsp; I'll probably use this in the future as well.&lt;/P&gt;</description><link>http://www.willasrari.com/blog/microsoft-office-interop-outlook--c-for-outlook-searches/000330.aspx</link><pubDate>10/21/2008 1:32:06 PM</pubDate><author>Will Asrari</author></item><item><title>Dilbert &amp; Agile Programming</title><description>&lt;p&gt;Just saw this cartoon this morning. Late pass I'm sure ;)&lt;/p&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 494px; HEIGHT: 203px" height=182 alt="Dilbert &amp;amp; Agile Programming" src="http://i37.tinypic.com/2wrn985.gif" width=460&gt;&lt;/P&gt;</description><link>http://www.willasrari.com/blog/dilbert--agile-programming/000329.aspx</link><pubDate>10/8/2008 2:50:00 PM</pubDate><author>Will Asrari</author></item><item><title>Silverlight ObservableCollection Bug Will Be the Death of Me</title><description>&lt;P mce_keep="true"&gt;&lt;STRONG&gt;BUG:&lt;/STRONG&gt; Items are sorted correctly sometimes, other times not so much.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;FREQUENCY: &lt;/STRONG&gt;Intermittent, never when debugging and stepping through everything, always seems to happen when I'm not.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;RATING:&lt;/STRONG&gt; Probably the most painful bug I've worked on in some time.&lt;/P&gt;
&lt;P mce_keep="true"&gt;So I've got an ItemsControl in a custom XAML user control.&amp;nbsp; All this does is display an IEnumerable&amp;lt;T&amp;gt; of video items.&amp;nbsp; Simple.&amp;nbsp; To provide a better user experience we implemented an ObservableCollection&amp;lt;T&amp;gt; as the source of the ItemsControl with a Collection_Changed event so we can add one item at a time to the collection so as to not wait for the entire collection to populate before displaying to the user.&amp;nbsp; Now we're able&amp;nbsp;to display the first 2 items and the scrollbar height shrinks as items are being added.&amp;nbsp; It's a nice user-experience.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Anyway, so for the implementation.&amp;nbsp; When the VideoRetrieveComplete event fires (after making a web service request for the data) we call the UpdateVideoCollection method.&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#2b91af&gt;
&lt;P&gt;UIThread&lt;/FONT&gt;.Run(&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;delegate&lt;BR&gt;&lt;/FONT&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;videoListControl.UpdateVideos(args.VideoItems);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;videoListControl.itemsControlVideoListing.DataContext = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;VideoItem&lt;/FONT&gt;();&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Notice that we're doing this in the UI Thread.&amp;nbsp; The code above is located in our Controller class.&amp;nbsp; The args.VideoItems is an IEnumerable&amp;lt;VideoItem&amp;gt; and they are sorted in the order they need to be in.&amp;nbsp; I have verified this time and time again with painful debugging.&lt;/P&gt;
&lt;P&gt;Now time for VideoList controls properties, objects, and methods:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;public&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; CurrentPageIndex { &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;get&lt;/FONT&gt;; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;set&lt;/FONT&gt;; }&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;ObservableCollection&lt;/FONT&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;VideoItem&lt;/FONT&gt;&amp;gt; ObservableCollection { &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;get&lt;/FONT&gt;; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;set&lt;/FONT&gt;; }&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;List&lt;/FONT&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;VideoItem&lt;/FONT&gt;&amp;gt; VideoItems = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;List&lt;/FONT&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;VideoItem&lt;/FONT&gt;&amp;gt;();&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Constructor where everything is initialized.&amp;nbsp; Probably important to include this.&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;public&lt;/FONT&gt; VideoList()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;CurrentPageIndex = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObservableCollection = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;ObservableCollection&lt;/FONT&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;VideoItem&lt;/FONT&gt;&amp;gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;itemsControlVideoListing.ItemsSource = ObservableCollection;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObservableCollection.CollectionChanged += CollectionChanged;&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;public&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; UpdateVideos(&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;List&lt;/FONT&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;VideoItem&lt;/FONT&gt;&amp;gt; videoItems)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;UIThread&lt;/FONT&gt;.Run(&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;delegate&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&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;&amp;nbsp;VideoItems.AddRange(videoItems);&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;&amp;nbsp;ObservableCollection.Clear();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&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;&amp;nbsp;if&lt;/FONT&gt; (VideoItems != &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;null&lt;/FONT&gt; &amp;amp;&amp;amp; VideoItems.Count &amp;gt; 0)&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;&amp;nbsp;{&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;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;VideoItem&lt;/FONT&gt; videoItem = VideoItems[0];&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;VideoItems.RemoveAt(0);&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObservableCollection.Add(videoItem);&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;&amp;nbsp;}&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;});&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;void&lt;/FONT&gt; CollectionChanged(&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt; sender, &lt;/FONT&gt;&lt;FONT color=#2b91af&gt;NotifyCollectionChangedEventArgs&lt;/FONT&gt; e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (VideoItems.Count &amp;gt; 0)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UIThread&lt;/FONT&gt;.Run(&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;delegate&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;&amp;nbsp;&lt;/FONT&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;VideoItem&lt;/FONT&gt; videoItem = VideoItems[0];&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;VideoItems.RemoveAt(0);&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObservableCollection.Add(videoItem);&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;&amp;nbsp;});&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;The reason for removing an item, and then re-adding it is that this is the only way we can get our Converters to fire off, otherwise the collection hasn't changed and UI elements don't update.&amp;nbsp; For example, switching between tabs the user can add videos to their playlist.&amp;nbsp; Each time the tabs are selected and the VideoListing populates the VideoItems within that listing needs to show either an ADD / DELETE FROM PLAYLIST button depending on whether or not the item is in the playlist.&amp;nbsp; If there's another way to get those Converters to fire off I'm all ears.&lt;/P&gt;
&lt;P&gt;So the problem is that more often than not the videos, which come in sorted correctly, are not always displayed that way.&amp;nbsp; For example, if I have&amp;nbsp;5 videos with dates 10/1/2008, 10/1/2008, 9/30/2008, 9/29/2008, 9/28/2008 sometimes the sort will be:&lt;/P&gt;
&lt;P&gt;10/1/2008&lt;BR&gt;9/30/2008&lt;BR&gt;9/29/2008&lt;BR&gt;9/28/2008&lt;BR&gt;10/1/2008&lt;/P&gt;
&lt;P&gt;or:&lt;/P&gt;
&lt;P&gt;9/30/2008&lt;BR&gt;9/29/2008&lt;BR&gt;10/1/2008&lt;BR&gt;9/28/2008&lt;BR&gt;10/1/2008&lt;/P&gt;
&lt;P&gt;You get the idea.&amp;nbsp; Could it be that we are not implementing this correctly?&amp;nbsp; Do we need to rebind the ItemsControl or is this correct?&lt;/P&gt;
&lt;P&gt;I've been working on this bug for a day and a half now and have nothing.&amp;nbsp; I'm sure it's probably something stupid.&lt;/P&gt;
&lt;P&gt;I'm all ears if you have anything. ANYTHING!&lt;/P&gt;
&lt;P&gt;Oh, should probably add that if I page to the next listing of videos and then back it'll remedy itself!&lt;/P&gt;</description><link>http://www.willasrari.com/blog/silverlight-observablecollection-bug-will-be-the-death-of-me/000328.aspx</link><pubDate>10/2/2008 5:37:11 PM</pubDate><author>Will Asrari</author></item><item><title>What's Wrong With This Picture?</title><description>&lt;P&gt;Tried to debug a new Silverlight application today.&amp;nbsp; By new I mean it was hosted in a different web project then the one I had been previously working on due to the fact that I needed to test some stuff locally.&amp;nbsp; I was trying for about half an hour to get this thing to debug.&amp;nbsp; The application would start to load up and then just hang on the loading animation.&amp;nbsp; A co-worker told me to make sure I had the Silverlight debugger checkbox checked.&amp;nbsp; I then go into the appropriate property tab and am greeted with this:&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="what's wrong with this picture? (image)" src="http://i37.tinypic.com/2ibndrc.png"&gt;&lt;/P&gt;
&lt;P&gt;I remember this debugger option used to be located in the appropriate Debuggers group box.&amp;nbsp; Apparently when I performed my Visual Studio 2008 and .NET Framework updates my Visual Studio 2008 UI ended up getting mutated.&lt;/P&gt;
&lt;P&gt;Very strange.&lt;/P&gt;</description><link>http://www.willasrari.com/blog/whats-wrong-with-this-picture/000327.aspx</link><pubDate>10/1/2008 5:42:23 PM</pubDate><author>Will Asrari</author></item><item><title>Way to Go Vista File Transfers!</title><description>&lt;P&gt;Better grab a lunch, or 9.&lt;/P&gt;
&lt;P&gt;&lt;img src="http://i35.tinypic.com/2vbv502.png" /&gt;&lt;/P&gt;</description><link>http://www.willasrari.com/blog/way-to-go-vista-file-transfers/000326.aspx</link><pubDate>9/18/2008 5:54:28 PM</pubDate><author>Will Asrari</author></item><item><title>The Zune Update Totally Sucks</title><description>&lt;P&gt;Updated the Zune application software this morning at about 7:00am.&amp;nbsp; Since I had no choice in the matter, I went ahead and did it ;)&lt;/P&gt;
&lt;P&gt;Wow.&amp;nbsp; Talk about a change... for the worst.&amp;nbsp; The application seems to lag a lot even when I have nothing else open.&amp;nbsp; If I try to listen to it with Visual Studio 2008, SQL Management Studio, and Outlook forget about it.&amp;nbsp; Too bad because those are all the things I use on a daily basis for work.&amp;nbsp; That's also when I listen to the most of my music.&lt;/P&gt;
&lt;P&gt;Luckily I've got 4 stereos in the house wired up to my Zune player so depending on where in the house I'm working (laptop) I can listen to my music.&amp;nbsp; I've also got 2 30GB zunes for this and am thinking of buying another when the new line is released (if it hasn't been already).&lt;/P&gt;
&lt;P&gt;Like any Microsoft product there will be a patch released for the Zune software if enough people are experiencing these symptoms and at the end of the day I'm still glad I don't use any Apple products.&lt;/P&gt;
&lt;P&gt;Does anyone else find that the Zune software responds a lot like a poorly-written RIA (rich internet application)?&amp;nbsp; To me it responds like Silverlight applications do when they are first written; before any story board animations / overlays are added to let the user know that SOMETHING is actually happening.&amp;nbsp; Just a thought....&lt;/P&gt;
&lt;P&gt;If anyone from Zune reads this you might want to update the Zune Card widget (see left navigation column) to utilize Silverlight instead of Flash.&amp;nbsp; It would probably be a good look since, you know; you're Microsoft and you have this new technology you want to promote.&lt;/P&gt;
&lt;P&gt;Looks like I'll try this again later.&amp;nbsp; Maybe rebooting (again) will help.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;&lt;BR&gt;Unresponsiveness of the application aside, the hardware update seems to be pretty sweet! Now I can play games while listening to tasty licks by The Chameleons.&amp;nbsp; The wireless feature is pretty sweet. I wonder if I &lt;EM&gt;have&lt;/EM&gt;&amp;nbsp;to be at one of 9,800 McDonald's restaurants to be able to download?&amp;nbsp; I'd guess not...&lt;/P&gt;</description><link>http://www.willasrari.com/blog/the-zune-update-totally-sucks/000325.aspx</link><pubDate>9/18/2008 12:42:02 PM</pubDate><author>Will Asrari</author></item><item><title>No Generic List FindAll Method in Silverlight 2 Beta 2</title><description>&lt;P&gt;Came across a need this morning to use the &lt;A href="http://msdn.microsoft.com/en-us/library/fh1w7y8z.aspx"&gt;FindAll&lt;/A&gt; method. To my dismay it wasn't there.&amp;nbsp; I know that Silverlight uses a subset of the .NET Framework but the System.Collections.Generic namespace is definitely there.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="System.Collections.Generic namespace in Silverlight 2 Beta 2" src="http://i36.tinypic.com/20fbvpk.png"&gt;&lt;/P&gt;
&lt;P&gt;You can clearly see that I'm using the namespace in the above image.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="ReSharper List.FindAll Error Silverlight 2 Beta 2" src="http://i34.tinypic.com/35bcnxv.png"&gt;&lt;/P&gt;
&lt;P&gt;Here you can see that ReSharper's background compiling caught it right away. For a second there I thought: "You know, maybe ReSharper is full of shit. This can't be right."&amp;nbsp;I tried to compile to make sure (which was the case with the version 4 nightly builds).&lt;/P&gt;
&lt;P&gt;
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;'System.Collections.Generic.List&lt;STRING&gt;' does not contain a definition for 'FindAll' and no extension method 'FindAll' accepting a first argument of type 'System.Collections.Generic.List&lt;STRING&gt;' could be found (are you missing a using directive or an assembly reference?)&lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Weird.&lt;/P&gt;</description><link>http://www.willasrari.com/blog/no-generic-list-findall-method-in-silverlight-2-beta-2/000324.aspx</link><pubDate>9/4/2008 11:38:25 AM</pubDate><author>Will Asrari</author></item><item><title>Hacking Silverlight, ObservableCollections, &amp; Scarface</title><description>&lt;P&gt;In working with Silverlight lately I've found that there's not a lot of documentation, especially for more complex functionality.&amp;nbsp; More times than not I find myself sort of scratching my head and wondering if the solution provided is really the best way to accomplish a certain task.&lt;/P&gt;
&lt;P&gt;Let's say you're creating an application that serves up articles (i.e. for a library search application).&amp;nbsp; You have an ItemsControl that uses a article item control as it's DataTemplate. The ItemsSource of this ItemsControl is an &lt;A href="http://msdn.microsoft.com/en-us/library/ms668613.aspx"&gt;ObservableCollection&lt;/A&gt;&amp;lt;T&amp;gt; of type, I don't know; SearchResult.&amp;nbsp; The DataContext for your ItemsControl is, you guessed it; SearchResult.&lt;/P&gt;
&lt;P&gt;Now say you have, above your search results, a little panel that provides filtering.&amp;nbsp; The filters are List&amp;lt;T&amp;gt; -bound that expand&amp;nbsp;when clicked (and roll up when done).&amp;nbsp;In keeping with our library search application let's pretend the filters are by year (Last Week, Last Month, Last Year, Last 2 Years, etc....) and by topic (Sociology, Psychology, Political Science, Computer Science, etc..).&amp;nbsp; The year filter allows you to select only one (the selection of a listitem triggers the list to hide and the listing of articles below to refresh).&amp;nbsp; The user can select any number of topics.&amp;nbsp; Each listitem in the topic filter has an overlay that provides button functionality such as "SELECT / DESELECT, CLEAR ALL, DONE".&amp;nbsp; When you select an item, it highlights that row.&amp;nbsp; DESELECT unhighlights the row.&amp;nbsp; DONE means you are done selecting and rolls (hides) the list back up.&amp;nbsp; CLEAR ALL&amp;nbsp;is the problem child.&amp;nbsp; Behind the scenes we are storing the id for the listitem in a List&amp;lt;T&amp;gt;.&amp;nbsp; We have easy access to these on MouseLeftButtonUp due to our DataContext being set earlier.&amp;nbsp; Clicking done will trigger the enumeration of this list to build our query and then that is sent to a web service.&amp;nbsp; There is a subscription to the ArticleRefresh trigger and the ItemsControl listing is updated. Easy.&lt;/P&gt;
&lt;P&gt;The issue is the unhighlighting of all the listitems&amp;nbsp;in the topic list upon clicking CLEAR ALL.&amp;nbsp; That sounds really easy (and it may very well be!) but I haven't seemed to figure out an efficient way to do this.&lt;/P&gt;
&lt;P&gt;In ASP.NET it was extremely easy to enumerate all the controls from within, let's say a Repeater.&amp;nbsp; You have in your ItemTemplate a control that you want to repeat.&amp;nbsp; You could write a little bit of code to enumerate every RepeaterItem and alter the display of certain text and controls within that Repeater.&amp;nbsp; It's extremely easy.&lt;/P&gt;
&lt;P&gt;In Silverlight you don't have that luxury.&amp;nbsp; Well, you're supposed to have an easier way of doing business but I haven't yet found it.&amp;nbsp; By the way, I'm talking about Silverlight 2 Beta 2.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;My first attempt at this was to create a Converter that sets the IsSelected property based on the presence of the topic's id in the List&amp;lt;T&amp;gt; it is bound to.&amp;nbsp; I get a BAD_PROPERTY_VALUE error when that is attempted.&lt;/P&gt;
&lt;P&gt;The next attempt was creating an event handler for the Loaded event of my topic filter control that will cast the sender to the filter object, check to see if the id of the objects DataContext is contained in the List&amp;lt;T&amp;gt;.&amp;nbsp; If it is, highlight, else, no highlight.&amp;nbsp; This works the first time the application is loaded but not on subsequent list views.&amp;nbsp; Reason being the use of the ObservableCollection&amp;lt;T&amp;gt;.&amp;nbsp; The collection itself hasn't changed, so no rebinding needs to occur.&amp;nbsp; This is probably a good thing.&amp;nbsp; What if the collection had 100's, 1000's of items?&amp;nbsp; Makes for quick UI responsiveness.&lt;/P&gt;
&lt;P&gt;The only way I have found to accomplish this is instantiating an IEnumerable object, setting its collection to that of the ObservableCollection&amp;lt;T&amp;gt; that the filter list is bound to (public property), then setting said public property&amp;nbsp;to this IEnumerable object that is, in a sense, the same exact thing.&amp;nbsp; This way the collection has changed (sort of), and the &lt;A href="http://msdn.microsoft.com/en-us/library/ms653375.aspx"&gt;CollectionChanged&lt;/A&gt;&amp;nbsp;event now gets fired.&amp;nbsp; The list is re-bound and we start from scratch with no highlighted rows.&lt;/P&gt;
&lt;P&gt;That seems like kind of a hack to me.&amp;nbsp; Anyone else care to chime in?&lt;/P&gt;
&lt;P&gt;I'll try to get a code sample but this is one of those things that I had to voice out first.&amp;nbsp; I hope it's not too hard to follow.&amp;nbsp;&amp;nbsp; For some reason today I had Paul Engemann's "Push it to the Limit" in my head while trying out all sorts of different ways of accomplishing this task.&amp;nbsp; I kind of laughed to myself at the idea of a programming montage set to this song (kind of like in the South Park episode with the skiing contest. And, of course, &lt;A href="http://en.wikipedia.org/wiki/Scarface_(1983_film)"&gt;Scarface&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;For the first time EVER on this blog, musical accompaniment:&lt;/P&gt;
&lt;P&gt;&lt;EMBED src=http://www.youtube.com/v/hs510bgQa2I&amp;amp;hl=en&amp;amp;fs=1 width=425 height=344 type=application/x-shockwave-flash allowfullscreen="true"&gt;&lt;/P&gt;</description><link>http://www.willasrari.com/blog/hacking-silverlight-observablecollections--scarface/000323.aspx</link><pubDate>8/21/2008 10:18:26 PM</pubDate><author>Will Asrari</author></item></channel></rss>
