我想获取文本框值,我将根据该值下载excel列表。这是我的观点:
@using (Html.BeginForm("DownloadAttendeeExcel", "Attendee", FormMethod.Post, new { id = "downloadAttendee", @class = "stdform" }))
{ <div>
@Html.TextBoxFor(x => x.EventID, new { id = "eventID" })
</div>
<div>
@Html.TextBoxFor(x => x.EventName, new { id = "eventName" })
</div>
}
这是我的动作,但我无法根据文本框值设置model.eventID,我无法理解为什么。
public ActionResult DownloadAttendeeExcel(AttendeeListItem model)
{
Reservation res = new Reservation();
res.EventID = model.EventID;
return View();
}
答案 0 :(得分:4)
您的按钮:
<a class="btn" type="button" id="downloadAttendees" ref="@Url.Action("DownloadAttendeeExcel", "Attendee")" style="width: 150px;">
将执行HttpGet并且不会发布您的表单数据 指示表单提交内容(包含的所有输入字段)的最简单方法是使用html提交按钮:
<input type="submit" value="Submit">