<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>crunchlife: Tag Oops</title>
    <link>http://crunchlife.com/articles/tag/oops</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Subversion: Merging a Branch into Trunk</title>
      <description>&lt;p&gt;I can never remember how to merge a &lt;a href="http://subversion.tigris.org/" target="_blank"&gt;Subversion&lt;/a&gt; branch into trunk.  So for future reference, here is how it&amp;#8217;s done.&lt;/p&gt;

&lt;p&gt;First, get a working copy of the head revision of trunk.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;svn checkout svn://svnserver/project/trunk project&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Next, merge the branch with your working copy.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;svn merge svn://svnserver/project/trunk svn://svnserver/project/branches/branch project&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Finally, commit the results of the merge.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;cd project
svn commit -m &amp;quot;Merging branch X.X.X into trunk.&amp;quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can also specify a revision number in your merge.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;svn merge svn://svnserver/project/trunk@223 svn://svnserver/project/branches/branch@223 project&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That&amp;#8217;s it.&lt;/p&gt;</description>
      <pubDate>Tue, 25 Aug 2009 18:21:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:32e934ca-5772-409a-a579-b8c7692c38b4</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2009/08/25/subversion-merging-a-branch-into-trunk</link>
      <category>Code Snippets</category>
      <category>Oops</category>
      <category>SCM</category>
      <category>SVN</category>
    </item>
    <item>
      <title>Installing RMagick on Ubuntu*</title>
      <description>&lt;p&gt;Because I always forget how&amp;#8230;&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo apt-get install libmagickwand-dev
sudo gem install rmagick&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and you reference it in code like so:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# Don't forget the capital &amp;quot;RM&amp;quot;!&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;RMagick&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;RMagick&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;*I&amp;#8217;ve only done this using Ubuntu 9.04.  Your mileage may vary.&lt;/strong&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 20 Aug 2009 10:00:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:dbbef41a-92fd-4d04-85ad-a13ee582e634</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2009/08/20/installing-rmagick-on-ubuntu</link>
      <category>Code Snippets</category>
      <category>Oops</category>
      <category>Ruby</category>
      <category>Ubuntu</category>
    </item>
    <item>
      <title>Linksys NAS200 Disk Failure - Part 2</title>
      <description>&lt;p&gt;A few weeks ago I began &lt;a href="http://crunchlife.com/articles/2009/02/25/linksys-nas200-disk-failure" target="_blank"&gt; having problems&lt;/a&gt; with my Linksys NAS200.  At the time, I couldn&amp;#8217;t discern whether it was a hard drive failure or a problem with the NAS200&amp;#8217;s disk controller.  The status message within the NAS200&amp;#8217;s administrative panel suggested that the drive had been &amp;#8220;removed&amp;#8221;.  I received no alert message and proceeded to diagnose the problem to the best of my abilities.  &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/B001LDOJXE?ie=UTF8&amp;amp;tag=crunchlife-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B001LDOJXE"&gt;&lt;img border="0" src="/files/51-Bt7_X2PL._SL160_.jpg" class="right"&gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=crunchlife-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B001LDOJXE" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;After some thought, I devised a plan to back up the remaining good disk, power down the NAS200, and replace Disk 1 with a new hard drive.  I purchased an &lt;a href="http://www.amazon.com/gp/product/B001LDOJXE?ie=UTF8&amp;amp;tag=crunchlife-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B001LDOJXE"&gt;Eagle Consus M-Series external drive enclosure&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=crunchlife-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B001LDOJXE" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;
 and a spare Western Digital 500 GB hard drive for a total of $102.95.  I placed the order last Saturday and UPS delivered the package to my door on the following Tuesday.&lt;/p&gt;

&lt;p&gt;Last night I backed up the files on my Linksys NAS200 using the Eagle drive enclosure and a spare 250 GB SATA drive that I had laying around.  Transferring the files from my NAS200 to the external drive was painful.  At speeds between 900 KB/sec and 1.9 MB/sec, I decided to make a sacrifice and chose not to include my music and movie collection.&lt;/p&gt;

&lt;p&gt;Even without my media files the backup still took about nine hours to complete.  It&amp;#8217;s almost inevitable that &lt;a href="http://crunchlife.com/articles/2008/09/21/2-0" target="_blank"&gt;my wife is awake at 3 AM&lt;/a&gt;.  Before bed, I asked her to wake me up so that I could check on the progress of the backup.  I didn&amp;#8217;t want to risk having the USB drive enclosure overheat and foil my plans.  My wife is more cheerful than I am at 3 o&amp;#8217;clock in the morning.  She woke me up as planned and I stumbled from the bedroom to sit on the floor in front of the NAS200.  The backup was complete.&lt;/p&gt;

&lt;p&gt;Do not attempt to insert a hard drive into your NAS200 in the dark.  Remember the &lt;a href="http://crunchlife.com/articles/2007/08/03/review-linksys-nas200" target="_blank"&gt;puzzling &amp;#8220;ribbon&amp;#8221;&lt;/a&gt; that I found in each of the drive bays?  Well, half of the ribbon is encased in plastic.  I didn&amp;#8217;t even think about it last night and ended up turning Disk 1&amp;#8217;s ribbon into an accordion.  In the dark, at 3 AM, I thought the drive was properly seated.  I turned on the device and waited.  The Disk 2 LED lit up brightly.  I waited some more.  Disk 1 remained dark.  My wife turned on our living room lights and found me squatting on the floor holding the NAS200 inches from my face.  Within the glow of the incandescents I could tell what I had just done.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="/files/ribbon_fail.jpg" title="FAIL!" class="photo"&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;I had to shake the NAS200 (gently) to remove the disk that I had just securely wedged into the first drive bay.  Once the drive was removed I decided to try again in the morning.  With proper lighting and a few more hours of sleep, I carefully inserted the new drive and pressed the power button.  The NAS200 whirred and its lights began blinking.  Disk 2&amp;#8230; Disk 1&amp;#8230; Disk 1!  According to what I had previously read, The NAS200&amp;#8217;s disk LEDs alternate when mirroring.  My NAS200&amp;#8217;s lights were doing just that.&lt;/p&gt;

&lt;p&gt;After work I noticed that both disk lights were solid indicating that both drives were active.  I checked the NAS200&amp;#8217;s administrative panel and both drives were listed as &amp;#8220;Used by RAID 1&amp;#8221;.  Satisfied, I mounted the shares and proceeded to browse through my files.  Everything was there!&lt;/p&gt;

&lt;p&gt;My original &lt;a href="http://crunchlife.com/articles/2007/08/03/review-linksys-nas200" target="_blank"&gt;NAS200 review&lt;/a&gt; has over ninety comments and both the &lt;a href="http://forums.linksysbycisco.com/" target="_blank"&gt;Linksys community forums&lt;/a&gt; and &lt;a href="http://www.linksysinfo.org/" target="_blank"&gt;linksysinfo.org&lt;/a&gt; are filled with posts left by people inquiring about the device.  I&amp;#8217;ve read a lot of bad reviews and received quite a few disparaging comments regarding the reliability of the NAS200.  I bought it knowing it was new on the market.  Trusting the Linksys brand name, I figured it&amp;#8217;d be a sturdy device and for eighteen months it has been.&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s just as foolish to rely on a single device as it is a single hard drive for safe file storage.  Hardware will always fail.  That said, I&amp;#8217;ve begun to work on an off-site storage strategy for my home backups.  I&amp;#8217;ll be posting more on this when I&amp;#8217;ve worked out the details.&lt;/p&gt;</description>
      <pubDate>Wed, 25 Mar 2009 16:27:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:ba5fdaeb-59d1-4ab4-bf6e-c5759c2b5e42</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2009/03/25/linksys-nas200-disk-failure-part-2</link>
      <category>Expect the Unexpected</category>
      <category>Backups</category>
      <category>NAS</category>
      <category>Oops</category>
      <trackback:ping>http://crunchlife.com/articles/trackback/95</trackback:ping>
    </item>
    <item>
      <title>Linksys NAS200 Disk Failure</title>
      <description>&lt;p&gt;After 18 months of abuse, &lt;a href="http://crunchlife.com/articles/2007/08/03/review-linksys-nas200" target="_blank"&gt;my NAS200&lt;/a&gt; finally lost a hard drive. I heard a muffled beep this evening while working on a new design for this website. Thinking it was one of my daughter&amp;#8217;s many noisy toys, I dismissed the alarm and continued working.  About an hour ago I attempted to save my work to a share on the NAS200, but was greeted with this rather ambiguous error message.&lt;/p&gt;

&lt;div style="text-align: center;"&gt;
&lt;img src="/files/nas_error.png"&gt;
&lt;/div&gt;

&lt;p&gt;I could ping the device, but browsing to its administrative website resulted in a 404 error.&lt;/p&gt;

&lt;p&gt;The NAS200&amp;#8217;s power and Disk 2 lights were blinking in alternation. The Disk 1 indicator was not lit at all. My heart sank at this point. So I next did what all IT professionals do when disaster strikes. I hit the power button and said a small prayer. Unfortunately, my NAS200 would not shut down. I yanked its power cord from the wall, let it cool down, and plugged it back in. As the NAS200 powered up, its fan whirred and lights began blinking.&lt;/p&gt;

&lt;p&gt;After reboot, the NAS200&amp;#8217;s lights blinked in the same pattern as before, but this time I decided to wait a few minutes rather than have a panic attack. During this time the ACT light flickered rapidly for about 10 minutes.  When it finally went out, the power and Disk 2 lights stayed lit, but Disk 1 remained dark. At this point I was able to browse to the administrative website and view Disk 1&amp;#8217;s status. The drive appeared to be &amp;#8220;removed&amp;#8221;. Huh?&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m perplexed as to what this means. I did not receive a hardware failure e-mail and the &amp;#8220;removed&amp;#8221; status makes me think that the controller has failed rather than the disk itself.  Hmmm&amp;#8230; Disk 2 is still accessible so my plan is to back it up as quickly as possible and then proceed as if I&amp;#8217;m dealing with a disk failure. Wish me luck.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;*Update: The second part of this article can be found &lt;a href="http://crunchlife.com/articles/2009/03/25/linksys-nas200-disk-failure-part-2"&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 25 Feb 2009 19:58:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:14e3cd72-3e2d-4bc6-8b61-1483a8b38713</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2009/02/25/linksys-nas200-disk-failure</link>
      <category>Expect the Unexpected</category>
      <category>NAS</category>
      <category>Oops</category>
      <enclosure type="image/png" length="16506" url="http://crunchlife.com/files/nas_error.png"/>
    </item>
    <item>
      <title>System.Net.Mail.SmtpFailedRecipientException and Exchange 2007</title>
      <description>&lt;p&gt;I&amp;#8217;d recently been struggling with a .NET application that sends email via SMTP through Exchange 2007 outside of my domain at work.  That is, until I found &lt;a href="http://stackoverflow.com/questions/444210/how-do-i-send-emails-outside-my-domain-with-exchange-2007-and-c" target="_blank"&gt;a workaround&lt;/a&gt; that uses the Exchange 2007 Pickup folder.  This eliminated my authentication hassles and resolved the dreaded &lt;strong&gt;Mailbox unavailable. The server response was: 5.7.1 Unable to relay&lt;/strong&gt; error.  I&amp;#8217;ve posted the solution here, but I also suggest reading &lt;a href="http://stackoverflow.com/questions/444210/how-do-i-send-emails-outside-my-domain-with-exchange-2007-and-c" target="_blank"&gt;the original post&lt;/a&gt;.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;SmtpClient smtpClient = new SmtpClient(&amp;quot;EXCHANGESRV&amp;quot;, 25) {
    DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory,
    PickupDirectoryLocation = &amp;quot;\\EXCHANGESRV\PickupFolder&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Keep in mind that you&amp;#8217;ll either need sufficient write permission on the Pickup folder or be able to impersonate somebody that does.  I happen to have &lt;a href="http://crunchlife.com/articles/2008/05/27/temporary-identity-impersonation-in-asp-net" target="_blank"&gt;written about identity impersonation&lt;/a&gt; a few months ago.  You&amp;#8217;re in luck.&lt;/p&gt;

&lt;p&gt;Kudos to &lt;a href="http://stackoverflow.com/" target="_blank"&gt;stackoverflow.com&lt;/a&gt;.  I only wish I had enough rep to upvote the submitter. :(&lt;/p&gt;</description>
      <pubDate>Fri, 30 Jan 2009 09:45:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:732e970b-8123-45a8-90e6-214f6938c382</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2009/01/30/system-net-mail-smtpfailedrecipientexception-and-exchange-2007</link>
      <category>Code Snippets</category>
      <category>Expect the Unexpected</category>
      <category>dotNET</category>
      <category>Oops</category>
    </item>
    <item>
      <title>Samba Network Shares with Nautilus in Hardy Heron Part 2</title>
      <description>&lt;p&gt;&lt;img src="/files/ubuntu_logo.png" class="right"&gt;Nearly a month ago I wrote about my &lt;a href="http://crunchlife.com/articles/2008/04/28/samba-network-shares-with-nautilus-in-hardy-heron" target="_blank"&gt;problems connecting to the network shares&lt;/a&gt; of my &lt;a href="http://crunchlife.com/articles/2007/08/03/review-linksys-nas200" target="_blank"&gt;Linksys NAS200&lt;/a&gt; using Nautilus in Ubuntu, Hardy Heron. My fix was simple and it worked. Unfortunately, the solution&amp;#8217;s &lt;a href="http://en.wikipedia.org/wiki/Woman_acceptance_factor" target="_blank"&gt;WAF (Wife Acceptance Factor)&lt;/a&gt; was low. Apparently she didn&amp;#8217;t think it was easy enough to execute smbmount from a Terminal window. Whatever :) I have since written a small shell script that is called from Session Startup.&lt;/p&gt;

&lt;p&gt;Initially, the script failed to connect to my network shares because my wireless network connection hadn&amp;#8217;t finished negotiating before the script was executed. I coded around this by creating a while loop that &lt;a href="http://en.wikipedia.org/wiki/Grep#Usage_as_a_conversational_verb" target="_blank"&gt;greps&lt;/a&gt; the output of a ping to my router. If successful, the mount_shares function is called. Otherwise. the thread will sleep for 10 seconds and try again.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#!/bin/bash

user=&amp;quot;thorbardin/ryan%password&amp;quot;
root_dir=&amp;quot;/home/ryan/Network Shares&amp;quot;

mount_shares() {
  public_dir=&amp;quot;$root_dir&amp;quot;/&amp;quot;Public on Thorbardin&amp;quot;
  home_dir=&amp;quot;$root_dir&amp;quot;/&amp;quot;Home on Thorbardin&amp;quot;

  [ -d &amp;quot;$public_dir&amp;quot; ] || mkdir -p &amp;quot;$public_dir&amp;quot;
  [ -d &amp;quot;$home_dir&amp;quot; ] || mkdir -p &amp;quot;$home_dir&amp;quot;

  smbmount &amp;quot;//192.168.1.105/public disk&amp;quot; &amp;quot;$public_dir&amp;quot; -o user=&amp;quot;$user&amp;quot;
  smbmount &amp;quot;//192.168.1.105/ryan&amp;quot; &amp;quot;$home_dir&amp;quot; -o user=&amp;quot;$user&amp;quot;
}

while [ 1 ]; do
  if ping -c2 192.168.1.1 2&amp;gt;&amp;amp;1 | grep ttl; then
    mount_shares

    exit 0   
  fi
  sleep 10
done

exit 0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I&amp;#8217;m already thinking about rewriting this script so that it scans my network using &lt;a href="http://www.menet.umn.edu/docs/software/samba/3.0.14a/help/smbtree.1.html" target="_blank"&gt;smbtree&lt;/a&gt; and automatically mounts all available network shares. That&amp;#8217;ll be Part 3!&lt;/p&gt;</description>
      <pubDate>Sun, 01 Jun 2008 16:07:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:d387ed9b-c3b3-469c-8052-8514021774bc</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/06/01/samba-network-shares-with-nautilus-in-hardy-heron-part-2</link>
      <category>Code Snippets</category>
      <category>NAS</category>
      <category>Ubuntu</category>
      <category>Oops</category>
      <category>Bash</category>
      <trackback:ping>http://crunchlife.com/articles/trackback/67</trackback:ping>
    </item>
    <item>
      <title>ASP.NET AJAX Control Toolkit: Transparent Tab Control Images</title>
      <description>&lt;p&gt;I&amp;#8217;ve found a use for the &lt;a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Tabs/Tabs.aspx" target="_blank"&gt;Tab Control&lt;/a&gt; that is included with the &lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=AtlasControlToolkit" target="_blank"&gt;ASP.NET AJAX Control Toolkit&lt;/a&gt;. The control&amp;#8217;s default style is passable for now, but I&amp;#8217;ve grown tired of looking at the white borders surrounding active tabs. If your background is not white, you&amp;#8217;ve probably noticed this too.&lt;/p&gt;

&lt;p&gt;To fix this, I&amp;#8217;ve edited the images and posted them &lt;a href="/files/new_tab_images.zip"&gt;here&lt;/a&gt;. I&amp;#8217;m not sure why the two active tab images were missed when all of the other images have transparent borders. Here are the before and after shots. Please don&amp;#8217;t use these.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;
  &lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;strong&gt;Before&lt;/strong&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;img src="/files/tab_before.jpg"&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&lt;img src="/files/tab_after.jpg"&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 10 Apr 2008 08:18:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:627c5337-e4af-4ad3-a252-daee75d87df0</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/04/10/asp-net-ajax-control-toolkit-transparent-tab-control-images</link>
      <category>ASPNET</category>
      <category>Ajax</category>
      <category>Oops</category>
      <enclosure type="application/x-zip" length="468" url="http://crunchlife.com/files/new_tab_images.zip"/>
      <trackback:ping>http://crunchlife.com/articles/trackback/53</trackback:ping>
    </item>
    <item>
      <title>Setting Focus in ASP.NET Ajax Pages</title>
      <description>&lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/B000YJ2OJ2?ie=UTF8&amp;amp;tag=crunchlife-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B000YJ2OJ2"&gt;&lt;img border="0" src="/files/316ZntjzQ2L._AA_SL160_.jpg" class="photo right"&gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=crunchlife-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B000YJ2OJ2" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;At the new job I&amp;#8217;ve been using a lot of &lt;a href="http://www.asp.net/ajax/" target="_blank"&gt;ASP.NET Ajax&lt;/a&gt; to help ease the transition of users from &lt;a href="http://en.wikipedia.org/wiki/VB6" target="_blank"&gt;VB6&lt;/a&gt; desktop applications to web applications on our company &lt;a href="http://en.wikipedia.org/wiki/Intranet" target="_blank"&gt;intranet&lt;/a&gt;. In doing this, the UpdatePanel has become my new best friend. Albeit charming, my old ASP.NET 2.0 friends were not as impressed.&lt;/p&gt;

&lt;p&gt;With ASP.NET 2.0, came the long-awaited &lt;a href="http://aspnet.4guysfromrolla.com/articles/111506-1.aspx" target="_blank"&gt;Focus&lt;/a&gt; method that allowed developers to set the page focus without having to write any JavaScript. Developers loved it and all was right with the world. That is until ASP.NET Ajax showed up.&lt;/p&gt;

&lt;p&gt;I recently spent way too much time trying set the page focus on a page that contained just a few TextBox controls and an UpdatePanel. My site&amp;#8217;s ScriptManager was located in a MasterPage, but more on that later. My obligatory googling turned up many work arounds, but none as simple as the following:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;// Example

if (Page.IsPostback)
{   
    // Use the GetCurrent method if your ScriptManager is located
    // in a MasterPage. Word.
    ScriptManager.GetCurrent(this.Page).SetFocus(TextBox1);
}
else
{
    // Here is the money.
    AjaxControlToolkit.Utility.SetFocusOnLoad(TextBox2);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The above example is a two-fer. The ScriptManager&amp;#8217;s SetFocus method is handy, but remember that only one ScriptManager is allowed per page and if you&amp;#8217;ve put your ScriptManager in a MasterPage, then you&amp;#8217;ll need to access it in code using the GetCurrent method of the ScriptManager class. &lt;/p&gt;

&lt;p&gt;Two. The ASP.NET 2.0 UpdatePanel is not the only Ajax control. Download the &lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=AtlasControlToolkit" target="_blank"&gt;ASP.NET Ajax Control Toolkit&lt;/a&gt;. With this toolkit, you&amp;#8217;ll have access to dozens of controls and best of all &amp;#8211; the SetFocusOnLoad method. Located in the Utility class, the SetFocusOnLoad method is the answer to your !Page.IsPostback problems.&lt;/p&gt;</description>
      <pubDate>Mon, 31 Mar 2008 15:24:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:a059a73f-ed79-457f-9df5-24ab32e0fdd7</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/03/31/setting-focus-in-asp-net-ajax-pages</link>
      <category>Code Snippets</category>
      <category>ASPNET</category>
      <category>Ajax</category>
      <category>Oops</category>
      <enclosure type="image/jpeg" length="9085" url="http://crunchlife.com/files/316ZntjzQ2L._AA_SL160_.jpg"/>
      <trackback:ping>http://crunchlife.com/articles/trackback/52</trackback:ping>
    </item>
    <item>
      <title>Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'</title>
      <description>&lt;p&gt;&lt;img src="/files/brick.jpg" class="right"&gt;Just a quick fix.  If you&amp;#8217;re experiencing the error message, &lt;strong&gt;Cannot convert type &amp;#8216;ASP.login_aspx&amp;#8217; to &amp;#8216;System.Web.UI.WebControl&lt;/strong&gt;, try renaming your page from Login.aspx to something else.&lt;/p&gt;

&lt;p&gt;I ran across this earlier this morning when attempting to deploy an ASP.NET 2.0 WebSite project. My code worked great locally (isn&amp;#8217;t that always the case). I haven&amp;#8217;t had time to really dig into why this happens, but maybe someone else can provide an answer.&lt;/p&gt;</description>
      <pubDate>Thu, 28 Feb 2008 10:38:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:dfb541d1-36a9-49d2-ae21-d2f6078645c1</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/02/28/cannot-convert-type-asp-login_aspx-to-system-web-ui-webcontrols-login</link>
      <category>ASPNET</category>
      <category>Oops</category>
      <enclosure type="image/jpeg" length="46540" url="http://crunchlife.com/files/brick.jpg"/>
      <trackback:ping>http://crunchlife.com/articles/trackback/50</trackback:ping>
    </item>
    <item>
      <title>Expect the Unexpected: Irony</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;a href="http://news.bbc.co.uk/2/hi/americas/7108835.stm" target="_blank"&gt;&lt;img src="/files/explorer.jpg"&gt;&lt;/a&gt;&lt;/center&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 26 Nov 2007 21:45:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:d8feb3c5-21bf-4ff7-b9dc-0accb5468303</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2007/11/26/irony</link>
      <category>Expect the Unexpected</category>
      <category>Oops</category>
      <enclosure type="image/jpeg" length="40598" url="http://crunchlife.com/files/explorer.jpg"/>
    </item>
    <item>
      <title>Code Snippet: Turning Oops into Ahah with Ruby.</title>
      <description>&lt;p&gt;&lt;a href="http://www.creativememories.com/" target="_blank"&gt;Scrapbooking&lt;/a&gt; is my wife&amp;#8217;s favorite hobby (stay with me). To fuel her passion, she takes hundreds of pictures at each family function with her digital camera. She edits the pictures, uploads them to &lt;a href="http://www.yorkphoto.com" target="_blank"&gt;yorkphoto.com&lt;/a&gt;, and then checks and rechecks our mailbox daily for the printed pictures. With the pictures finally in hand, she manages to combine the photos, bits of paper, stickers, and collected mementos to create a beautifully designed scrapbook page. Each page in her album is an original work. I&amp;#8217;m constantly amazed and secretly jealous of her improving sense of design. &lt;/p&gt;

&lt;p&gt;The Oops:&lt;/p&gt;

&lt;p&gt;The camera my wife uses is a &lt;a href="http://www.usa.canon.com/consumer/controller?act=ModelInfoAct&amp;amp;fcategoryid=145&amp;amp;modelid=9449" target="_blank"&gt;Canon PowerShot A80&lt;/a&gt;. It names each digital image with a sequential number that starts at 1 with the very first picture taken. In exploring the camera&amp;#8217;s settings, I managed to reset the picture count. So rather than her next picture having a file name of IMG&lt;em&gt;_&lt;/em&gt;103995837284942 it was named IMG_1. No big deal. Wrong! This messed up her entire workflow. Apparently my wife used the image&amp;#8217;s file name as a unique identifier. Copying newly taken pictures to her working directory would have overwritten hundreds of files. Oops!&lt;/p&gt;

&lt;p&gt;The Ahah:&lt;/p&gt;

&lt;p&gt;To fix my blunder, I planned on renaming all of her archived images with a &lt;a href="http://en.wikipedia.org/wiki/Universally_Unique_Identifier" target="_blank"&gt;UUID&lt;/a&gt;. That way none of her images would be overwritten when adding the new pictures. Normally I would have written a bash script to handle this, but since I&amp;#8217;d been spending some time with Ruby I thought I&amp;#8217;d take the opportunity to learn from my mistake. It worked! The code from my image renaming script can be found below.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;#!/usr/bin/ruby&lt;/span&gt;

&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rubygems&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;uuid&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;file_path&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/home/wifename/Desktop/Pictures&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;destination_path&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/home/wifename/Pictures&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;file_types&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;jpg&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;jpeg&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;gif&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;png&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;xcf&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt;

&lt;span class="constant"&gt;Dir&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;file_path&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/*.*&lt;/span&gt;&lt;span class="punct"&gt;'].&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
    &lt;span class="ident"&gt;file_extension&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;split&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;.&lt;/span&gt;&lt;span class="punct"&gt;').&lt;/span&gt;&lt;span class="ident"&gt;last&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;downcase&lt;/span&gt;
    &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;file_types&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;include?&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;file_extension&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;then&lt;/span&gt;
        &lt;span class="ident"&gt;file_name&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;UUID&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;
        &lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;rename&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;destination_path&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="ident"&gt;file_name&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;.&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="ident"&gt;file_extension&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Finished...&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With the above script, I was able to undo my mistake and learn while doing so. Now if only she didn&amp;#8217;t have to use the command-line to run the code. Does anyone have experience with widget toolkits in Ruby? If so, contact me.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Jul 2007 08:49:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:5e210883-0419-446b-baa1-f223a21475e3</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2007/07/12/code-snippet-turning-oops-into-ahah-with-ruby</link>
      <category>Code Snippets</category>
      <category>Oops</category>
      <category>Ruby</category>
    </item>
  </channel>
</rss>
