我一直在研究ASP MVC3但是提交按钮没有响应,如果我使用URL Action
(<button type="button" class="submitBtnYellow" id="DateSubmit1" onclick ="location.href='@Html.Action("MarketAdmin", "AdminDashboard", FormMethod.Post)'" >)
将其重定向到GET
并且模型为空,但我的{{1} }无法正常工作
控制器如下
POST
视图如下
[HttpPost]
public ActionResult MarketAdmin(Reports report)
{
//my Code
return View();
}
[OutputCache(Location = OutputCacheLocation.None, Duration = 0)]
public ActionResult MarketAdmin( )
{
//my Code
return View();
}
@using XXXX.AdminPortal.Helpers;
@model XXXX.Domain.Model.Reports
@{
ViewBag.Title = "Reports";
}
@using (Html.BeginForm("MarketAdmin", "AdminDashboard", FormMethod.Post, new { enctype = "multipart/form-data", id = "AdminDashboard" }))
{
<html>
<head>
<title></title>
//代码继续
$(document).ready(function () {
$("#StartDate2").attr("readonly", "true");
$("#EndDate2").attr("readonly", "true");
$("#StartDate2").datepicker({ maxDate: -1 });
$("#StartDate").datepicker({ maxDate: -1 });
$("#EndDate2").datepicker({ maxDate: -1 });
$("#EndDate").datepicker({ maxDate: -1 });
$('#DateSubmit2').click(function () {
alert(startDate1); alert(endDate1);
var startDate1 = $('#StartDate2').datepicker('getDate');
var endDate1 = $('#EndDate2').datepicker('getDate');
if (startDate1 == null) {
alert("Please enter Start Date.");
$("#StartDate2").val("");
$("#StartDate2").focus();
return false;
}
else {
if (endDate1 == null) {
alert("Please enter End Date.");
$("#EndDate2").val("");
$('#EndDate2').focus();
return false;
}
else {
if (startDate1 >= endDate1) {
alert("Start Date should be less the End Date");
$("#StartDate2").val("");
$('#StartDate2').focus();
return false;
}
}
}
// $("#StartDate").val(startDate1);
alert(startDate1);
alert(endDate1);
});
我已经尝试了,但它是对GET进行重新设计并且模型值为空
任何人都可以帮我这个吗?