July 2009 Entries

Resource Files and ASP.NET MVC Projects

If you try some of the traditional ASP.NET approaches to localization and internationalization in an MVC application you’re likely to run into a couple interesting* obstacles. Resx Files In App_GlobalResources Using resource files in App_GlobalResources from your controller code will break your unit tests. When you drop a .resx file in the special App_GlobalResources folder, the IDE uses the GlobalResourceProxyGenerator to generate a strongly typed internal class to wrap the resources inside. The internal class gives any code in the MVC project access to the resources: var greeting = Resources.Strings.Greeting; You can also use the resources from a view: <%= Html.Encode(Resources.Strings.Greeting) %> The problem is...

Geeky Places to Visit In & Near Maryland

Maryland has a number of geek attractions inside and around its borders. Here’s a sampling: National Air & Space Museum There are two locations to visit. The museum on the National Mall is in the heart of D.C. and features over 20 exhibition galleries that include an Apollo 11 command module, lunar rocks, IMAX theater, and planetarium. For truly colossal exhibits you’ll want to head ~22 miles out of town to the Steven F. Udvar-Hazy Center. Located just off the approach to Dulles airport’s runway 1R, the museum includes the space shuttle Enterprise, and an SR-71 Blackbird. You shouldn’t need...

Event Aggregation with jQuery

As the “write less, do more” library, jQuery garners lots of love for its terseness. The terseness, combined with a rich ecosystem of plug-ins, means I can display my OdeToCode twitter feed on a web page using only 10 lines of code (complete with animation and custom loading message)*. $(function() { $("#getTweets").click(function() { $("#tweets").getTwitter({ userName: $("#screenname").val(), numTweets: 10, ...

Pretty Code #1 – Building SelectListItems

In ASP.NET MVC, you can use a collection of SelectListItems to help build an HTML . Just watch out for the HTML helper overloads. The question is – what is the prettiest code that can change a list of Products into a collection of SelectListItems? Tonight, you’ll be the judge in this first contest of charm, grace, and readability. Contestant #1 hails from the System.Web.Mvc namespace. It likes pina coladas and string literals, but is turned off by tattoos that look like programming symbols. Let me introduce the SelectList class: var products = GetProducts(); var selectItems = new SelectList(products, "ID",...

Three IIS Concepts ASP.NET Developers Should Know

It’s possible to do a lot of work with ASP.NET and not know anything about IIS, particularly if you work with a large team where IT specialists keep the riff-raff away from production web applications. Ever since Visual Studio started shipping its own web server1, many people don’t rely on IIS for day to day development work (although many of us still do). ...