List/detail views with MVC 3 and AJAX

25 January 2011

List / detail views with MVC 3 and AJAX

In my quest to master Razor I tried to get a list/detail view up and running spiced up with a dash of AJAX and it turned out to be surprisingly easy – the code needed is available below. I used the OmniCorp demo site for this spike and the code is using the ‘News’ data type from that site – if you want to duplicate this behavior you should update the name space references to ‘Omnicorp.Content’ and the ‘News’ type and it’s fields. Here are the steps needed to replicate this sample:

  1. Set up a OmniCorp demo site and install the MvcPlayer – this process is described in a previous blog post.
  2. Copy in the controller class below (to your ~/App_Code folder)
  3. Create the folder ~/Views/News and copy in the two views shown below.
  4. Add an instance of the MvcPlayer function to a page and specify "/News" as path – save, publish and browse to your test page to try it out.

The controller

Presentation no longer available

The views

Presentation no longer availablePresentation no longer available

  ASP.NET  Data  MVC

comments powered by Disqus