我正在尝试使用下拉列表和onchange将参数发送到操作。我试过发送这样的硬编码值:
onchange =“this.form.action ='/ Profile / Edit / 16
工作正常,但现在我想从这里找到的隐藏ID中发送值:
@ Html.HiddenFor(model => model.StudentID)
......做这样的事情:
@Html.DropDownList("DropDownValue", new SelectList(ViewBag.sellectedSubjects, "text"), "select one", new { onchange = "this.form.action='/Profile/Edit/@model => model.StudentID';this.form.method='get';this.form.submit();" })
当我这样做时,我收到“错误请求”错误。如何将我的Html.HiddenFor中的值作为参数发送到onchange?谢谢你的帮助!
答案 0 :(得分:0)
尝试:
@Html.DropDownList("DropDownValue", new SelectList(ViewBag.sellectedSubjects, "text"), "select one", new { onchange = "this.form.action='/Profile/Edit/"+Model.StudentID+"';this.form.method='get';this.form.submit();" })