Monthly Archives: October 2008

While reviewing my latest post’s outbound click-through stats, I noticed that most of you found Rik Lomas’ quickSearch more interesting than the rest. In light of that interest, I’ve decided to show you an example of how you might implement its functionality in conjunction with ASP.NET.

For this demonstration, I’m going to use Delicious as a source of sample data to apply the technique to. I’m sure you’re getting tired of my RSS feed as demo data, and the Delicious API provides an abundance of topical data via jQuery tag feeds.

In this post I will show you how to use LINQ to XML to query the Delicious API, display that data in a table, apply the quickSearch plugin to that table, work around a problem that arises when using quickSearch with ASP.NET, and lay the groundwork for a “no results” state.

That request would return an RSS document describing the 25 most recent items appearing on the “popular” list for the jQuery tag. The actual XML returned for each item would look something like this (slightly abridged):

Now that we have a handle on how to request the data and what the data looks like, we can easily build a LINQ to XML expression to query the API.

Using LINQ to XML to query the API

If you’ve dealt with XPath for querying XML documents in the past, you’re going to love LINQ to XML. For example, these few lines of code are all that is required to execute the API request and extract a collection for databinding:

The only tricky aspect of this is rendering the tags. Since those are contained in a List<string> nested inside each item’s Tags property, we need to nest a Repeater within the ItemTemplate to iterate over and display each item’s tags.

The trick to this is assigning the Tags property as the datasource for each of the nested Repeater controls. Using the SeparatorTemplate of a comma, we get a CSV rendering of the strings in the Tags List.

With a bit of CSS styling, our rendered table looks something like this:

Using quickSearch to implement progressive search

Now that we’ve built an appropriate table of data, using quickSearch to implement the progressive search functionality is the easiest step:

It should make sense now why rendering the <tbody> was important. It provides us an avenue to more easily construct a jQuery selector which correctly identifies the DOM elements that we intend to identify as searchable content.

If you’re new to jQuery, the position option may give you trouble at first. Position has four possible values which match corresponding jQuery manipulation functions: prepend, append, before, and after. See those documentation pages for examples of how each option works, relative to the attached element.

Note: When quickSearch is attached to a table, avoid using prepend or append. Inserting its form inside a table’s markup will cause bad things to happen.

Now, if only that had worked

There’s one big problem with all of this: it doesn’t work!

You probably know that ASP.NET WebForms controls, such as the Repeater used above, must be enclosed within a <form runat=”server”> element. However, what you may not have known is that the quickSearch plugin renders itself in a form tag as well.

Unfortunately for us, HTML simply does not allow nested form elements. So, if you try to render the quickSearch interface within a WebForm, things don’t go well.

Some browsers handle this nested form problem gracefully, but others don’t. In any case, you certainly should not rely on the browser correcting this for you.

Making it work

In this simple example, we could attach quickSearch above the WebForm’s <form> element and it would work. That isn’t a good general solution though.

So, I updated the plugin to render a <div> instead of a <form>. Problem solved.

The modified version is included in the source download below. Feel free to use it in your own projects.

Displaying a “no results” message

A commenter on my last post made a good point, mentioning that the plugin lacks support a “no results” message when your search string filters all elements.

By adding an onAfter event handler, we can easily add that functionality ourselves:

Windows only: Convert videos from DVD or downloads into the format and size you like with Automen, a simple but powerful tool that’s small, free, and relatively easy to use. I say “relatively” compared to Mencoder, the command-line utility it provides a user interface for. You will have to edit the program’s INI configuration file in Notepad to get it working, so if drag-and-drop is more your speed it might not be right for you. You can choose from a variety of input and output formats (including XVID, FLV, WMV, and MP4), specify the output dimensions and even target file size, batch-process multiple videos and the software will take full advantage of multi-core processors to speed up encoding. For alternative tools, check out our top 10 free video rippers, encoders, and converters. Automen is a free download for Windows.

Ubuntu 8.10, the “Intrepid Ibex” release of the free, open-source Linux distribution, is officially out and available for download. This release doesn’t bring much huge or startlingly new to Ubuntu, but does smooth out some rough edges and improves the Wi-Fi, 3G, and portability experience. Check out our full screenshot tour of Intrepid Ibex to see what’s inside, and if your ISO downloads or upgrades are going slow today, read up on upgrading using BitTorrent or grabbing updates and ISOs from a mirror server. There’s also one or two new tools we didn’t catch earlier this month in the final release, which we’ll peek at below. Ubuntu 8.10 is a free download; it can run as a live CD or install on most Intel-based systems.

Ubuntu 8.10 includes a simple, working tool that puts a bootable Ubuntu system on a memory stick and lets you use persistent space on it to store settings and documents—in other words, keep a real Home folder there. I really wish, however, that you didn't have to download an Ubuntu ISO to make the disk, or that it could at least point you to a list of mirrors to find one on. In a perfect world, it would just create your USB disk from your current system, removing any specific hardware references and the like. As it is, though, it's a pretty handy tool for any spare thumb drives you've got.

Also new in the release candidate and final versions of 8.10 is a “System Cleaner” applet. I couldn’t dirty my brand-new desktop quick enough to give a good screenshot, but the Cleaner will apparently show any unneeded and abandoned software packages hanging around your system, and will also alert you to bad or leftover lines in your /etc/fstab (drive configuration), /etc/X11/xorg.conf (display and device manager), and all the other files you want to back up before messing with. If it works as promised, it’s a pretty good step toward that “for humans” slogan the distro touts.

Well I finally made it to the finish line. This episode covers the hinge installation, pegging the tenons in the doors, making custom ebony handles, and finishing. I end the video with a justification of my design.

If you are interested in the Gripper system I showed for cutting small parts, you can pick one up in our Amazon.com Store. And if you are looking for the finishing DVD I mentioned, you can find that right here.

The Macworld blog offers a few tips on doing comparison shopping between the major MP3 music stores. With Wal-Mart having recently slash prices on their online music tracks, the author recommends Safari uses create a web clip of the store’s Top Albums page and use a dashboard widget to search both the iTunes and Amazon store. There are a handful of other worthy links worth checking, including feeds of iTunes deals and free tracks, but the true discount is finding music for free. Read on for a few humble suggestions on doing that.

Find your tunes on the web

Our own Adam Pash has written the book on comprehensive web searching for a free album or song across the web’s many and varied sites. From music blog aggregator Hype Machine to straight-up MP3 searches with BeeMP3, if you can't find it on one of those sites, you've got a tried and true friend: A Google search that returns MP3s in open directories. Here's the string—just replace the "Album" and "Artist" and the like with your intended find:

Grab it from a friend

If your friend’s just blatantly insisting that you check out this new album that’s going to blow your mind, you could always just ask him to share his MP3s through a share-friendly online storage service—unless that friend bought their album off the iTunes store. If they can bring an iPod loaded with the tracks to your crib, you can copy music from iPod to computer, no matter what model they’re rocking. If there’s a distance factor, try having them install and share tracks with Mojo. The software has its quirks, but it often gets the job done. If they’re DRM-protected tracks, you might try doubleTwist or DVDneXtCopy’s faux-CD-burner. Those without legit access to an iTunes-bought track, though, will likely have to beg a friend to burn a CD, and then import it with a bit of audio quality loss.

Grab the audio from a video

Bands want to see their songs promoted, so they take their show on tour, do press interviews, and, more than that, make videos for their singles. If you’re looking for just such a song, why not use the audio that’s already floating around for free? Free web tools like Vixy and VidToMP3 automatically grab tracks from YouTube or other video URLs. Want a bit more control over audio quality and track format? Try reader Matt’s suggested method for recording YouTube music videos to MP3.

Update: Finally, as Coldmiser points out, your local library, especially in a larger metropolitan area, often has a pretty decent selection of CDs for borrowing and, if you’re cool with it, importing to your collection.

How do you save money, or search for deals, when you’re actually buying MP3s? What tools do you use to check whether a song or album is available free before dropping the cash? Tell us your techniques in the comments.

A while back I built a small table that was originally intended for my son to use. But it hasn't made it in his room yet.

This project was built in a single day and with materials I picked up at my local home center. It's made entirely of No.2 common pine and a pre-laminated board. Total cost, under $30.

It’s a quick build and a great way to spend sometime in the shop just refining some skills or making new ones depending on how you build it.

This is part 1 of what will be a 4 or 5 part series each Wednesday. Also, you may have noticed there's an audio only version of today's episode too. Just trying a little something for those of you who like the audio shows also! Let me know how it goes.

Next Wednesday, November 5 another LIVE WTO is happening!! More information to follow!

Hendrik's back in November and we're taking your questions on table saws. Whether it's regarding setting up, safety or cutting, get your questions in early.

Also, if you'd like to enter for free schwag, have a comment, question or suggestion drop me a line at mattsbasementworkshop@gmail.com, head over to the website where you can also leave your comments, or you can leave a voicemail at 231 354-2338.

Controls are where it’s at these days in the programming world. By using them you maximize re-use, enhance productivity and avoid building custom functionality. Plus, when you need a control to do something different you can always extend it rather than writing everything from scratch.

If you’ve used ASP.NET AJAX then you’ve likely used controls from toolkits such as the ASP.NET AJAX Control Toolkit in your applications. Microsoft has also released a Silverlight Toolkit with new controls and functionality that can be used in Silverlight 2 applications. The controls are grouped into “quality bands” with the existing controls currently fitting into either the “Preview” or “Stable” bands. Additional information about quality bands and the toolkit controls can be found on Shawn Burke’s blog.

Controls included in the Silverlight Toolkit include:

AutoCompleteBox

ButtonSpinner

Chart

DockPanel

Expander

HeaderedItemControl

HeaderedContentControl

ImplicitStyleManager

Label

NumericUpDown

TreeView

ViewBox

WrapPanel

The new controls live in the Microsoft.Windows.Controls.dll assembly which contains several namespaces such as Microsoft.Windows.Controls (where most of the controls live) and Microsoft.Windows.Controls.DataVisualization.Charting (where the charting control and related classes live). To get started using them you’ll need to reference the Microsoft.Windows.Controls assembly provided in the toolkit and then add the controls to your Visual Studio 2008 Toolbox by right-clicking on it and selecting “Choose Items”. Select the Silverlight Components tab, browse to the assembly and then check the checkbox next to the controls you’d like to add and then drag them into a Silverlight 2 XAML file. This will add the proper namespace onto the UserControl root element as shown next:

In this post I’ll discuss a few of the new controls that I personally find quite useful and show what they’re are capable of doing. Future posts will drill into different controls and demonstrate additional details about how they can be used.

Managing Silverlight Styles with ImplicitStyleManager

In a previous post I wrote about how styles can be defined and assigned to controls. While the default technique of defining and applying styles works, it certainly can be a pain to add Style=”{StaticResource YourStyleKey}” to all of the controls needing to pick-up a specific style in an application. WPF provides a way to “implicitly” apply styles to controls but this functionality isn’t available in Silverlight 2 unfortunately. Enter the ImplicitStyleManager provided by the Silverlight Toolkit. By using ImplicitStyleManager styles that target a specific control type can be applied without manually adding a Style attribute to each control. The class lives in the Microsoft.Windows.Controls.Theming namespace (Microsoft.Windows.Controls assembly) which needs to be referenced in the XAML file as shown next:

Here’s an example of using ImplicitStyleManager within a control that has styles defined locally within its Resources section:

This example applies the styles to the appropriate controls (a Button and a TextBox in this case) automatically. The theming:ImplicitStyleManager.ApplyMode attribute makes this possible. Looking at the control definitions in the StackPanel you’ll see that no Style attribute is added. Instead, the styles are “implicitly” applied based on the Style element’s TargetType. You may also note that no x:Key is defined on the Style elements since it’s not needed.

ImplicitStyleManager can also be used to apply styles defined in a theme file (a XAML file containing a ResourceDictionary section) as shown next:

A portion of the CustomTheme.xaml file referenced by the code above is shown next:

Test pilot wanted

Looking for people who is interested in auto sport to become a TestFlight pilot for up-coming new release of AR1 iPhone APP.
During the TestFlight you will have access to the latest auto news and content from iPhone.