Can someone kindly let me know how can we pass on a argument from the view to controller, which loads the model.
In the below model, TaskNames gets loaded in a multi select box and MonthEnd gets loaded in a drop down box.
Model
public class TaskAssignModel
{
public List<string> TaskNames { get; set; }
public List<Task> Tasks { get; set; }
public List<MonthEndObj> MonthEnd;
}
Whenever i change the MonthEnd dropdown box ,Tasknames should be loaded based on the value selected in the MonthEnd dropdown.
How is this achievable ? Would like to know if there is a way to get this done through ajax.
***Controller****
public ActionResult AssignMonthEnd()
{
TaskAssignModel tm = new TaskAssignModel();
DataAccess DA = new DataAccess();
tm.Tasks = new List<Task>();
tm.Tasks = DA.getTasks();
tm.MonthEnd = DA.getActiveMonthEnd();
return View(tm);
}
View
@Html.ListBoxFor(m => m.TaskNames, new MultiSelectList(@Model.Tasks, "TaskID", "TaskName", @Model.TaskNames), new { style = "height:200px; width:400px;overflow-x: scroll", size="5"})
@Html.DropDownListFor(m => m.MonthEnd, new SelectList(Model.MonthEnd,"ActiveMonthEnd","ActiveMonthEnd",0))