Posts Tagged ‘ASP.NET’

ASP.NET MVC 1.0 is finally out.  Download it now!

At first glance, upgrading to the RC1 was quite a debacle. First of all, any link that I created using the much more performant Html.RouteLink (instead of Html.ActionLink) just stopped working. It turns out there was a regression bug in the RC that caused this. The ASP.NET MVC team quickly released a refresh which fixed the problem.

The next problem came when I noticed Stephen Walther’s paging helper stopped working. It would throw a null reference exception whenever I used the Html.Pager() helper method. The issue was a breaking change in the RC1 with the location the RequestContext.

To fix the issue, you can download the solution from Stephen’s site. Open up the solution and change all the references to the latest ASP.NET MVC assemblies. When you compile the main project, you’ll find an error in the PagerBuilder.cs class at line 165. All you have to do is update this line to:

var urlHelper = new UrlHelper(_helper.ViewContext.RequestContext);

Compile the project and replace the assembly in your ASP.NET MVC project. I’m sure Stephen will update the project eventually so you could just download the latest version.

Hope this helps!

First of all, an apology for being so quiet over the past few weeks.  I’ve been putting my blogging aside for a while to chase some pet projects I’m working on.  More on that later.

I did, however, run into a particular situation that I thought would be of interest to anyone adopting ASP.NET MVC and looking for some goodies from jQuery.  Many of you have no doubt started testing the waters with jQuery since it was announced that Microsoft will be shipping the next version of .NET with it included.  If you haven’t used jQuery yet, prepare to fall in love!  

In this post, I’m going to cover a simple way to build a deep, hierarchical and feature-rich tree structure with only one line of jQuery script.  jQuery has a huge library of plugins covering all sorts of functionality.  For this, we’ll be using a neat plugin from for treeviews.  Here’s what you need:
jQuery Treeview Plugin

This structure will consist of a category/sub-category relationship that is able to support n-levels of sub-categories with no changes.  To demonstrate, let’s look at the SQL table that supports the structure.

Notice the rows with ParentCategoryID set to NULL are the parent categories.  Each row with a ParentCategoryID is a sub-category and relates to it’s parent category.  The numbers show the level in outline view.

The jQuery Treeview plug-in requires the resulting HTML to be in a particular unordered list (<ul>) element to parse the tree correctly.  Since we don’t know how many levels to expect, we are going to call the MVC user control that renders each node recursively.  This control accepts a single Category item. 


We render the name of that category and then check if it has any categories associated with it.  If it does, we recursively render the control again.

In the controller, we are simply passing in the categories where the ParentCategoryID == null.


On the host view (Index.aspx), we create the root unordered list with an ID of “treeview” and pass in an array of the Parent categories (categories where the ParentCategoryID == null) from the controller. 


Here’s a look at the output WITHOUT the jQuery magic.

Now all we have to do is add the libraries we’re going to use and hook up the Treeview plugin.

Note:  I always use the jQuery script from the Google API’s.  By referencing it from Google’s server, you get to ride along their CDN, compression, etc. capabilities.  As an added bonus, if your user has already visited a site that referenced the same library, the jQuery library would be cached on their browser so they don’t take the hit of having to download it again.  Sweet!

In our jQuery script, we just get the ul’s element ID and call the plugin’s treeview() method with no options. 


When we refresh the page, we see jQuery has done its magic and now we have collapsable, rich tree view.

There’s a ton more options in the Treeview plugin that you can check out for yourself, including async loading with ajax, and tons of customizations.  ASP.NET MVC and jQuery – a match made in heaven!

Hope this helps!

I’ve been feverishly adapting and experimenting with the ASP.NET MVC Framework since the very first CTP.  I must admit, it keeps getting better with every release.  This past week was the official BETA release and I’m loving it.

It has been a challenge for developers new to the concepts of MVC to find reference samples to help architect MVC web applications.  For this, I’ve suggested to look towards more mature MVC frameworks such as Ruby on Rails for common patterns in MVC applications.  RoR is not difficult to read and you’ll certainly be able to follow the program logic.  I’ve HIGHLY recommend you take a look at this white paper exploring RESTFul Rails and then see how you can apply it to ASP.NET MVC.

UPDATE:  Installation of .NET 3.5 SP 1 on my web hosting completely killed this app!  I’m currently going through the process of upgrading it but it will be down for a while.

I am officially announcing the beta release of the GiftListr for Facebook application.

GiftListr is the only truly universal gift registry allowing you to add products from ANY website without limitations.  Just browse stores the way you usually do when you shop online.  Once you find the item you want, simply copy-and-paste the url into the GiftListr application.  GiftListr will then download all the product information and product images available.  You can add notes to each item and share you gift list with friends.

The application is built entirely on ASP.NET MVC and makes extensive use of the jQuery library.  It also uses the Facebook Developer Toolkit available on CodePlex.  I would love to hear some feedback from the ASP.NET community.  Let me know what you think.  Any features you’d like to see?  Would you be willing to contribute to it if I add it to CodePlex as a community project?