我想将参数传递给操作方法,但是我无法执行以下操作,这是我按钮的代码
<div class="button-wrapper"><div class="clearfix btn-topmarge">
<div class=""><input id="btnApply" type="submit" name="Apply" value="Apply"
class="btn btn-crud" onclick="Reset()" />
<input id="btnClear" type="reset" name="Clear" value="Clear" class="btn btn-
crud clear-btn" />
<input id="btnExcel" type="button" name="Excel" value="Export To Excel"
class="btn btn-crud"
onclick="location.href='@Url.Action("ExportBookingToExcel","Bookings", new
{EmployeeIds = Model.EmployeeIds == null ? null : string.Join(",",
Model.EmployeeIds), ApprovalStatus = Model.ApprovalStatus == null ? null :
string.Join(",", Model.ApprovalStatus),fromDate = ViewBag.FromDate, toDate =
ViewBag.ToDate, depDate = ViewBag.DepDate,page = Model.PageNumber })'" />
</div>
</div>
</div>
答案 0 :(得分:1)
“无法执行”不是对您的问题的很好解释。一定要用JavaScript调用(location.href
)吗?如果没有,我将整个 btnExcel 输入替换为:
@Html.ActionLink("Export To Excel", "ExportBookingToExcel", "Bookings", new { EmployeeIds = Model.EmployeeIds == null ? null : string.Join(",", Model.EmployeeIds), ApprovalStatus = Model.ApprovalStatus == null ? null : string.Join(",", Model.ApprovalStatus), fromDate = ViewBag.FromDate, toDate = ViewBag.ToDate, depDate = ViewBag.DepDate, page = Model.PageNumber }, new { @class = "btn btn-crud" })
通过删除javascript部分(onclick
属性),可以确保它不是JavaScript问题,并且可以将链接悬停并查看其构造是否正确。