S
ShaileshAggarwal
Guest
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:-
View
<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()" })
</div>
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.
[HttpPost]
public ActionResult GetMR_NumbersForProject(RequisitionViewModel reqViewModel)
{
reqViewModel.ReqModel.Documents =
GetListFromSelectedValue(reqViewModel.ReqModel.SelectedProject)
return View(reqViewModel);
}
Can someone help me with this?
Continue reading...
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:-
View
<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()" })
</div>
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.
[HttpPost]
public ActionResult GetMR_NumbersForProject(RequisitionViewModel reqViewModel)
{
reqViewModel.ReqModel.Documents =
GetListFromSelectedValue(reqViewModel.ReqModel.SelectedProject)
return View(reqViewModel);
}
Can someone help me with this?
Continue reading...