如何在onchange事件中将Html.HiddenFor值作为参数发送?

时间:2013-02-15 23:36:53

标签: asp.net-mvc-3

我正在尝试使用下拉列表和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?谢谢你的帮助!

1 个答案:

答案 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();" })