I'm studing Microsoft ASP MVC framework. Here is a problem I encounterd:
I have a view with DropDownList containning a list of countries and another DropDownList for states. The OnChange event post the form back and then the controller sends data to the states drop down which should update. But the second DropDownList doesn't change. They stay as what it was before the refresh. What should I do to fix this.
Thanks in advance!
Edit: Call ModelState.Clear() in the second controller fix that problem. Thanks for all of you who offers suggestions! Really Thanks!
ASP.Net MVC provides a new mechanism for generating dynamic web pages. It is at a much lower level of abstraction than ASP.Net and as a result familiar features of ASP.Net like events are deliberately not supported.
Try reading this blog entry for an example of how to do what you want on the client side using JQuery. This fits nicely into the MVC approach
ASP.NET MVC is able to return a JSON format result, what you need to do then is just calling that Controller's Action via jQuery and then display the drop down. you can see the details here - http://setiabud.blogspot.com/2009/05/cascading-drop-down-with-aspnet-mvc.html