我有一张不久前工作的表格。我没有对视图进行任何更改,只对post方法进行了一些小的表面更改,但现在每当我点击提交按钮时,它甚至都不会调用post方法。这是我的观看代码:
@model MinimumInventory.WebUI.ViewModels.ProductInfoWithNote
<head>
<script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>
<script type="text/javascript">
$(document).ready(function () {
$('#UseForecast').click(function () {
var $this = $(this).is(':checked');
if ($this) {
$('#MinimumOnHandQuantity').attr("disabled", "disabled")
$('#ForecastMultiplier').removeAttr("disabled");
} else {
$('#MinimumOnHandQuantity').removeAttr("disabled");
$('#ForecastMultiplier').attr("disabled", "disabled")
}
});
});
</script>
</head>
<h2>Create Product Info</h2>
<div>
@Html.ActionLink("Back to List", "MinimumProductInfoList")
</div>
<h4>@(ViewBag.Message ?? string.Empty)</h4>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
<div class="form-group">
@Html.LabelFor(model => model.ItemCode, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-2">
@Html.EditorFor(model => model.ItemCode, new { htmlAttributes = new { @class = "form-control" } })
</div>
<div class="col-md-6">
@Html.ValidationMessageFor(model => model.ItemCode, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UseForecast, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-1">
@Html.EditorFor(model => model.UseForecast, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UseForecast, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.MinimumOnHandQuantity, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-1">
@Html.EditorFor(model => model.MinimumOnHandQuantity, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MinimumOnHandQuantity, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ForecastMultiplier, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-1">
@Html.EditorFor(model => model.ForecastMultiplier, new { htmlAttributes = new { @class = "form-control", @disabled = "disabled" } })
@Html.ValidationMessageFor(model => model.ForecastMultiplier, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.MaximumOHandQuantity, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-1">
@Html.EditorFor(model => model.MaximumOHandQuantity, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaximumOHandQuantity, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.MinimumOrderQuantity, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-1">
@Html.EditorFor(model => model.MinimumOrderQuantity, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MinimumOrderQuantity, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" name="create" value="Create" class="btn btn-default" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" name="createAndAnother" value="Create and Another" class="btn btn-default" />
</div>
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
我的帖子方法如下:
[HttpPost]
public ActionResult CreateMinimumProductInfo(ProductInfoWithNote productInfoWithNote)
{
我认为我不需要再展示post方法,因为它甚至不会调用该方法。视图名称为CreateMinimumProductInfo,因此我不需要明确键入名称。正如你所看到的,我有两个单独的提交按钮,它们都在上周工作。还有什么可能导致这个?