O'Reilly logo

ASP.NET MVC 2 Cookbook by Richard Kimber, Andrew Siemer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing an auto post-back with a select list

In this recipe, we are going to look at how to replicate another standard ASP.NET web forms feature. We frequently need to present a drop-down list as a form of navigation. When the user selects an item from the list, we want the form to post itself so that we can do something with the selected value.

How to do it...

  1. Start by opening up one of the previous recipes in the chapter and make sure that jQuery is referenced in the master page.
  2. Open the home controller in the Controllers directory. We're going to create a little helper method to generate a small list of articles.
    Controllers/HomeController.cs: private List<Article> GetArticles() { return new List<Article> { new Article { ID = Guid.Parse("f4838485-058d-4c82-b4f4-3bd8c81c7d09"), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required