Click here to Skip to main content
15,744,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried with Dropdown change method .But its not getting.

By Ajax method i am calling one more method and its not hitting.

What I have tried:

In controlller::::

        public ActionResult DropDownBasic()
            ViewBag.CountyList = new SelectList(az.GetCountryList(), "CountryId", "CountryName");
            ViewBag.Store = 1;
            ViewBag.StateList = new SelectList(az.GetStateList(), "StateId", "StateName");
           return View();

 public ActionResult DropDownBasic1(int CustomerId)
            ViewBag.CountyList = new SelectList(az.GetCountryList(), "CountryId", "CountryName");
            ViewBag.StateListById = new SelectList(az.GetStateList(CustomerId), "StateId", "StateName");

            return View();


    ViewBag.Title = "DropDownBasic";
    Layout = "~/Views/Shared/_Layout.cshtml";


@model  AZ.WebUI.Models.Input

    @Html.DropDownList("Moving", new SelectList(ViewBag.CountyList as SelectList,"Value","Text"),"Select City",new { Id = "Co", onchange =@"Fill();" })

    @Html.DropDownList("States", new SelectList(ViewBag.StateList as SelectList, "Value", "Text"),"Select state")


    function Fill() {
        var value = $("#Moving").val();
        if (value) {
                url: '@Url.Action("DropDownBasic1", "Customer")/' + value,
                type: 'GET',
                dataType: 'json',
                success: function (data) {


Updated 28-Feb-17 19:34pm

1 solution

change this
var value = $("#Moving").val();
var value = $("#Co").val(); // you have declared  Co as id

change it to
new { Id = "Co", onchange="Fill(this);" })

function Fill(obj) {
       var value = obj.value;
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900