我有一個視圖同時顯示學生,課程,主題。我有3個不同的控制器,每個控制器都有一個模型。MVC - 爲單個視圖調用多個控制器
我不想將3個不同的模型合併到一個模型中,然後進行單個控制器調用。相反,我想要3個不同的控制器並對這些控制器進行3次調用。如何實現這個目標?
public class ABCController : Controller
{
public ActionResult Students()
{
return View(RepositoryHelper.GetStudentList());
}
public ActionResult Courses()
{
return View(RepositoryHelper.GetCoursesList());
}
public ActionResult Subjects()
{
return View(RepositoryHelper.GetSubjectsList());
}
}
- 查看
using (Html.BeginForm("GetData", "University", FormMethod.Post, new { id = "parameters" }))
{
@:<table>
@:<tr><td>
@Html.DropDownList("Students")
@:</tr></td>
@:<tr><td>
@Html.DropDownList("Courses")
@:</tr></td>
@:<tr><td>
@Html.DropDownList("Subjects")
@:</tr></td>
@:</table>
@:<p><input type='submit' value='Submit></p>
}
感謝您的回覆。我知道ajax的方式。我也排除了第二個選項。 我在看有沒有什麼方法可以從srever側調用不同的控制器,並獲得這個成果。 – Vijay 2011-03-28 07:47:08