I must be missing something, but...
Say I have the following Ajax form:
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>
}
}
I want to use it to call an Action (AddTutorCourse) that has 3 params:
string TutorName: No problem here, I can get this from the model: Model.TutorName
I want the value of the "TutorRoleId" dropdownlist
I want the value of the "CourseId dropdownlist.
Ie, calliing AddTutorCourse should look like:
[HttpPost]
public virtual ActionResult AddTutorCourse(string username, int TutorRoleId, int CourseId)
{
// do whatever...
return View(service.ViewModel);
}
The Question is:
At runtime, how to get the values into the following bit of code (note ??):
开发者_开发知识库MVC.Admin.TutorEditor.AddTutorCourse(Model.TutorName, ??, ??)
Have you tried:
MVC.Admin.TutorEditor.AddTutorCourse(Model.TutorName, 0, 0)
精彩评论