Posts

Showing posts with the label Ajax

MVC - Cascading Lists using Ajax and jQuery

Image
Download Project Source I t seems like every project I'm on has a cascading list requirement.  The problem is common enough: once a value in one list is selected, a second sub-list is populated based on selections from the first.  One of the most common scenarios (as seen above) is selecting a Country, which populates a list of States or Provinces (or Cities for my example). In a recent project, an additional requirement of cascading multi-select lists was needed.  If the user selects multiple values in the first list, the second list should contain all of the sub-selections from all the selections in the first list. Typically in the past, this has been done via post-back to the server to populate the second list.  This has the disadvantage of refreshing the page, which means the user is stuck waiting.  However, in MVC, it is just as simple to use Ajax and Jquery to seamlessly populate the list without interrupting the user experience. First, the mo...