我必须遗漏一些东西,但是......
说我有以下Ajax表单:
using (Ajax.BeginForm(MVC.Admin.TutorEditor.AddTutorCourse(Model.TutorName, TutorRoleId, CourseId),
new AjaxOptions
{
UpdateTargetId = "TutorCourses",
OnBegin = "isValidPleaseWait",
LoadingElementId = "PleaseWait"
},
new { name = "AddTutorCourseForm", id = "AddTutorCourseForm" }))
{
<fieldset>
<legend>Add Course</legend>
<div class="editor-label">
@Html.LabelFor(model => model.AllCourses)
@Html.DropDownList("CourseId", Model.AllCourses, "-- Choose Course --", new { style = "width:180px;" })
</div>
<div class="editor-label">
@Html.LabelFor(model => model.TutorRoles)
@Html.DropDownList("TutorRoleId", Model.TutorRoles, "-- Choose Role --", new { style = "width:180px;" })
</div>
<input type="submit" value="Add Course" />
</fieldset>
}
}
我想用它来调用一个有3个参数的Action(AddTutorCourse):
字符串TutorName:这里没问题,我可以从模型中得到这个:Model.TutorName
我想要“TutorRoleId”下拉列表的值
我想要“CourseId下拉列表。
即,呼叫AddTutorCourse应该如下所示:
[HttpPost]
public virtual ActionResult AddTutorCourse(string username, int TutorRoleId, int CourseId)
{
// do whatever...
return View(service.ViewModel);
}
问题是:
在运行时,如何将值放入下面的代码中(注意??):
MVC.Admin.TutorEditor.AddTutorCourse(Model.TutorName,??,??)
答案 0 :(得分:1)
你试过了吗?
MVC.Admin.TutorEditor.AddTutorCourse(Model.TutorName, 0, 0)