Cascading dropdown in MVC Razor

Let us have two dropdown list. When one of them is changed the another one will populated. So far I know, the mvc dont have postback method. So, we are going to use javascripts and so on.
Here is our dropdowns. One is populated by the controller with the “DepartmentList” viewdata. And another one by the change event of the first one.
View
Now, add a javascripts change event for first dropdown which will call the “Test” function of the controller “Registration” and the function will return a JSON result. It is also sending a string named “did” consisting the selected value of the dropdown’s. After getting the result, bindings the text and values to the targeted dropdown.
javascripts
At last create a function which will return a JSON type result. Here, the function calls another one to make a list for the selected index. Don’t be afraid about the “clsDesignation”. Its a model class consiting Designation ID and Name.
csFunctions
Advertisements

One comment on “Cascading dropdown in MVC Razor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s