Cascading DropDownList in ASP.NET MVC - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Wednesday, April 4, 2012

Cascading DropDownList in ASP.NET MVC

Introduction  

In this article, I have described and written a simple sample showing how to implement cascading drop down lists in ASP.NET MVC. In this sample the user is presented with a list of countries. Once a country is selected, a new drop down list is appears showing the states in the selected country. 

Background

Although there are a few simpler samples of implementing a cascading drop-down list in ASP.NET MVC, most of them mix JavaScript and markup (i.e. they are not unobtrusive), and they don't work when deployed to IIS. Ideally you enhance functionality with JavaScript, you don't require it. To keep this sample as simple as possible, it doesn't implement the traditional server post back method used JavaScript is not available. Instead this sample shows best JavaScript/jQuery practices when using the jQuery.getJSON method to populate a drop-down list box. It is not meant to be a sample showing how to implement this functionality when JavaScript is not enabled. Implementing server postback to populate the ListBox when JavaScript is disabled is not difficult and not addressed in this sample.

No comments:

Post a Comment