Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:02:29+00:00 2026-06-12T01:02:29+00:00

This is the first time i write in this board. I’m an Italian student,

  • 0

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:

  1. 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?

  2. 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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:02:30+00:00Added an answer on June 12, 2026 at 1:02 am

    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

    public class Category
    {
      public ID { set;get;}
      public string Name { set;get;}
    }
    

    and dropdowns in the view are like this

    @Html.DropDownListFor(x => x.SelectedCategoryID, 
                      new SelectList(Model.Categories, "ID", "Name"), "Select")
    
    @Html.DropDownListFor(x => x.SelectedSubCategoryID, 
                      new SelectList(Model.SubCategories, "ID", "Name"), "Select")
    

    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 JSON format.

    <script type="text/javascript">
        $(function () {
            $("#SelectedCategoryID").change(function () {
                var self = $(this);
                var items="";
                $.getJSON("@Url.Action("Index", "GetSubCategories")?id="+self.val(),
                                                                      function(data){
                    $.each(data,function(index,item){
                      items+="<option value='"+item.ID+"'>"+item.Name+"</option>";
                    });
                   $("#SelectedSubCategoryID").html(items);
                });
            });
        });
    </script>
    

    Now you should have a GetSubCategories action method which returns list of (Sub) Categories in JSON Format

    public ActionResult GetSubCategories(int id)
    {
      List<Category> subCategoryList=new List<Category>();
      //to do : fill the list of (sub) categories to the
      // above list for the category id passed to this method.
      return Json(subCategoryList,Json.RequestBehaviour.AllowGet); 
    }
    

    2) Session should be good.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using this site so sorry for any bad formatting
This is my first time using Latex to write a letter. I am using
So I'm trying to write a parser in ANTLR, this is my first time
This is the first time I've used ReportLab, I have tried to make simple
This is my first time to write a program that sends mails. I don't
This is the first time that I write a TestMethod. Am I using Unit
This is my first time using map/reduce. I want to write a program that
This is my first time working with a WPF datagrid. From what I understand
this is my first time asking a question here. I tried to be well
This is my first time that I use WCF and Android. So, sorry for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.