Set Model property on combobox selection changed MVC RRS feed

  • Question

  • I have bound my view to a Model inside controller on Index action

    public ActionResult Index()
                RequisitionViewModel reqViewModel = new RequisitionViewModel();
                reqViewModel.ReqModel = GetModelData();
                return View(reqViewModel);

    Now there is a property in the model which is bound to combobox on the view. What I am trying to do now is when user selects a value in the combobox another combobox should get filled based on the selected value.
    I am looking for a solution to do this inside controller with the help of model. Is there any way to do it?

    Something like below:-


    <div class="form-group">
                @Html.LabelFor(x => x.ReqModel.Project, new { @class = "control-label" })
                @Html.DropDownListFor(x => x.ReqModel.Project, @Model.ReqModel.Project, new { @class = "form-control", onchange = "Project_Selection_Changed()" })

                function Project_Selection_Changed() {
                //How to call controller action method by passing entire model object?

    The problem is I dont know how to pass the entire model On comboBox selection changed.

            public ActionResult GetMR_NumbersForProject(RequisitionViewModel reqViewModel)
                reqViewModel.ReqModel.Documents = 
                return View(reqViewModel);
    Can someone help me with this?

    • Moved by CoolDadTx Wednesday, October 7, 2020 3:20 PM ASP.NET related
    Wednesday, October 7, 2020 9:48 AM

All replies

  • This forum is for C#-specific questions only. Please post questions related to MVC in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, October 7, 2020 3:20 PM