我创建了一个Sitefinity后端页面,在该页面上我添加了一个表单并提交按钮,我的问题是,当我提交页面时,只是重新加载页面,甚至没有碰到后端的断点。我已经检查过了,它甚至没有生成表单标记。
@using (Html.BeginForm("DownloadAdvertClicksReport", "Reports", FormMethod.Post))
{
<div class="form-group">
@Html.LabelFor(m => m.From, new { @class = "sixteenpx" })
@Html.TextBoxFor(m => m.From, null, new { @class = "form-control datepicker sixteenpx" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.To, new { @class = "sixteenpx" })
@Html.TextBoxFor(m => m.To, null, new { @class = "form-control datepicker sixteenpx" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.Advert, new { @class = "sixteenpx" })
@Html.DropDownListFor(m => m.Advert, (IEnumerable<SelectListItem>)Model.PublishedAdverts, new { @class = "form-control sixteenpx border-0" })
</div>
<button type="submit" id="download" class="btn btn-primary sixteenpx">Download report</button>
}
[HttpPost]
public ActionResult DownloadAdvertClicksReport(AdvertClicksViewModel viewModel)
{
return Content(string.Empty);
}
后端页面是asp.net Web表单页面,因此它们已经在顶部具有表单元素。
因此,您基本上是在尝试嵌套不可能的表格。
这就是为什么,对于这种情况,您需要使用@ Html.BeginFormSitefinity帮助器方法。