This is the first time i write in this board. I’m an Italian student, excuse me for my bad English. For a lot of time i have developed my web application with ASP.NET Web Forms; now would like to migrate to ASP.NET MVC framework. So I would like to ask about two question:
-
SCENARIO 1: I have two DropDownList ( elements) in a form in a view. First DropDownList contains a list of category: i would like that when change item in the first DropDownList the second is loading of a list of subcategorys automatically. In Web Forms i often used UpdatePanel for this job. But now in MVC i can’t use it. I have tryed to use jQuery AJAX but code don’t works. How can i implement this job? An example please?
-
SCENARIO 2: I have a step-by-step wizard forms. So, i need to pass (memorize) data step by step. Where can i memorize this data? In session? An advice?
Thanks very much,
Francesco.
1) You can use jQuery ajax to get the items for your second dropdown when user selects the first one.
Assuming your Category class looks like this
and dropdowns in the view are like this
Now have some javascript to listen to the change event of first dropdown and get the value, make an ajax call to the action method which accepts the category id and return a list of sub categories in
JSONformat.Now you should have a
GetSubCategoriesaction method which returns list of (Sub) Categories inJSONFormat2) Session should be good.