Html.ActionLink 根本不打电话
Html.ActionLink doesn't call at all
我在解决这个问题时遇到了一些问题。问题是,这是它唯一不起作用的地方,在我项目的其他地方它都工作得很好而且都是一样的。
这是我的 link:
<td class="col-sm-1 col-lg-1">@Html.ActionLink("Edit", "EditGrowWeek", "FinishedProductionMaintanance", new { @id = Model.growWeek.GWID }, new { @data_toggle = "modal", @data_target = "#editGrowWeek" })</td>
我的控制器:
[HttpGet]
public ActionResult EditGrowWeek(int id)
{
viewModel.growWeek = _ProductionGrowWeekRepository.GetOne(id);
return PartialView(viewModel);
}
[HttpPost]
//[ValidateAntiForgeryToken]
public ActionResult EditGrowWeek([Bind(Prefix="growWeek")] ProductionGrowWeek growWeek)
{
var growWeeks = _ProductionGrowWeekRepository.GetAll(growWeek.GProfileNo);
foreach (var week in growWeeks)
{
if (ModelState.IsValid)
{
_ProductionGrowWeekRepository.Edit(week);
}
}
return RedirectToAction("IndexGrowProfiles");
}
最后是我的观点:
@model SISCOM.ViewModel.FinishedProductionMaintananceViewModel
@{
Layout = null;
}
<div class="modal fade in" id="editGrowWeek" tabindex="-1" role="dialog" aria-labelledby="MyModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
@using (Html.BeginForm("EditGrowWeek", "FinishedProductionMaintanance", FormMethod.Post))
{
@*@Html.AntiForgeryToken()*@
<form id="form">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.growWeek.GWID)
@Html.HiddenFor(model => model.growWeek.CutSupplierCode)
@Html.HiddenFor(model => model.growWeek.DelvyWk)
@Html.HiddenFor(model => model.growWeek.Description_ID_)
@Html.HiddenFor(model => model.growWeek.Description_Product_)
@Html.HiddenFor(model => model.growWeek.Despatch)
@Html.HiddenFor(model => model.growWeek.FinishedDuration)
@Html.HiddenFor(model => model.growWeek.FinishedSite)
@Html.HiddenFor(model => model.growWeek.GapUpHandSite)
@Html.HiddenFor(model => model.growWeek.GapUpMCSite)
@Html.HiddenFor(model => model.growWeek.GerminationDuration)
@Html.HiddenFor(model => model.growWeek.GerminationSite)
@Html.HiddenFor(model => model.growWeek.Germinator)
@Html.HiddenFor(model => model.growWeek.GerminatorDuration)
@Html.HiddenFor(model => model.growWeek.GerminatorSite)
@Html.HiddenFor(model => model.growWeek.GProfileNo)
@Html.HiddenFor(model => model.growWeek.GrowWks1)
@Html.HiddenFor(model => model.growWeek.GrowWks2)
@Html.HiddenFor(model => model.growWeek.GrowWks3)
@Html.HiddenFor(model => model.growWeek.GrowWks4)
@Html.HiddenFor(model => model.growWeek.GrowWks5)
@Html.HiddenFor(model => model.growWeek.OrderWK)
@Html.HiddenFor(model => model.growWeek.PreGapDuration)
@Html.HiddenFor(model => model.growWeek.PreGapSite)
@Html.HiddenFor(model => model.growWeek.PrickOut)
@Html.HiddenFor(model => model.growWeek.PrickOutSite)
@Html.HiddenFor(model => model.growWeek.Priority)
@Html.HiddenFor(model => model.growWeek.ProdGrp)
@Html.HiddenFor(model => model.growWeek.ProdSeries)
@Html.HiddenFor(model => model.growWeek.ProdSeriesDetail)
@Html.HiddenFor(model => model.growWeek.ProductionGrowProfile)
@Html.HiddenFor(model => model.growWeek.RangeUpdateFlag)
@Html.HiddenFor(model => model.growWeek.Rooting_GermAssess)
@Html.HiddenFor(model => model.growWeek.SiteGrown)
@Html.HiddenFor(model => model.growWeek.SiteRange)
@Html.HiddenFor(model => model.growWeek.SiteSown)
@Html.HiddenFor(model => model.growWeek.Topping)
@Html.HiddenFor(model => model.growWeek.ToppingCode)
@Html.HiddenFor(model => model.growWeek.Transplant)
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.WksToDesp, "Weeks to despatch")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.WksToDesp, null, new { @class = "form-control", @placeholder = "Weeks to despatch" })
@Html.ValidationMessageFor(p => p.growWeek.WksToDesp, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.GapUp, "Gap up")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.GapUp, null, new { @class = "form-control", @placeholder = "Gap up" })
@Html.ValidationMessageFor(p => p.growWeek.GapUp, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Pinch1, "Pinch1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Pinch1, null, new { @class = "form-control", @placeholder = "Pinch1" })
@Html.ValidationMessageFor(p => p.growWeek.Pinch1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Pinch2, "Pinch2")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Pinch2, null, new { @class = "form-control", @placeholder = "Pinch2" })
@Html.ValidationMessageFor(p => p.growWeek.Pinch2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space1, "Space1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space1, null, new { @class = "form-control", @placeholder = "Space1" })
@Html.ValidationMessageFor(p => p.growWeek.Space1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space2, "Space2")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space2, null, new { @class = "form-control", @placeholder = "Space2" })
@Html.ValidationMessageFor(p => p.growWeek.Space2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space3, "Space3")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space3, null, new { @class = "form-control", @placeholder = "Space3" })
@Html.ValidationMessageFor(p => p.growWeek.Space3, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Check1, "Check1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Check1, null, new { @class = "form-control", @placeholder = "Check1" })
@Html.ValidationMessageFor(p => p.growWeek.Check1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Edit" class="btn btn-default" />
</div>
</div>
</form>
}
</div>
</div>
</div>
</div>
我到处都在检查,这个根本没有打电话……有什么想法吗?
P.S。 ...这可能是相关的,因此,在此页面上,(在呈现此部分的索引上)我的页脚正在代码中呈现在我页面中间的某个位置..
这没有多大意义,但就是这样。问题是每次我为那个 table 生成值时,它都会出于某种原因删除它后面的部分视图(如果有人能理解这种行为并且可以解释,请这样做。)
所以,我的这个页面的索引曾经是这样的:
<div class="tab-content col-md-9 col-lg-9 growProfilePage">
<div class="col-md-12 col-lg-12">
<div class="col-md-4">
@{ Html.RenderPartial("ListGrowProfiles");}
</div>
<div class="col-md-8">
@{ Html.RenderPartial("ListGrowWeeks");}
@{ Html.RenderPartial("EditGrowWeek");}
</div>
</div>
</div>
现在看起来像这样:
<div class="tab-content col-md-9 col-lg-9 growProfilePage">
<div class="col-md-12 col-lg-12">
@{ Html.RenderPartial("EditGrowWeek");}
<div class="col-md-4">
@{ Html.RenderPartial("ListGrowProfiles");}
</div>
<div class="col-md-8">
@{ Html.RenderPartial("ListGrowWeeks");}
</div>
</div>
</div>
一切正常(奇怪的是,在其他页面上它仍然像以前一样,在列表之后进行编辑并且它像那样工作)。
我在解决这个问题时遇到了一些问题。问题是,这是它唯一不起作用的地方,在我项目的其他地方它都工作得很好而且都是一样的。
这是我的 link:
<td class="col-sm-1 col-lg-1">@Html.ActionLink("Edit", "EditGrowWeek", "FinishedProductionMaintanance", new { @id = Model.growWeek.GWID }, new { @data_toggle = "modal", @data_target = "#editGrowWeek" })</td>
我的控制器:
[HttpGet]
public ActionResult EditGrowWeek(int id)
{
viewModel.growWeek = _ProductionGrowWeekRepository.GetOne(id);
return PartialView(viewModel);
}
[HttpPost]
//[ValidateAntiForgeryToken]
public ActionResult EditGrowWeek([Bind(Prefix="growWeek")] ProductionGrowWeek growWeek)
{
var growWeeks = _ProductionGrowWeekRepository.GetAll(growWeek.GProfileNo);
foreach (var week in growWeeks)
{
if (ModelState.IsValid)
{
_ProductionGrowWeekRepository.Edit(week);
}
}
return RedirectToAction("IndexGrowProfiles");
}
最后是我的观点:
@model SISCOM.ViewModel.FinishedProductionMaintananceViewModel
@{
Layout = null;
}
<div class="modal fade in" id="editGrowWeek" tabindex="-1" role="dialog" aria-labelledby="MyModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
@using (Html.BeginForm("EditGrowWeek", "FinishedProductionMaintanance", FormMethod.Post))
{
@*@Html.AntiForgeryToken()*@
<form id="form">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.growWeek.GWID)
@Html.HiddenFor(model => model.growWeek.CutSupplierCode)
@Html.HiddenFor(model => model.growWeek.DelvyWk)
@Html.HiddenFor(model => model.growWeek.Description_ID_)
@Html.HiddenFor(model => model.growWeek.Description_Product_)
@Html.HiddenFor(model => model.growWeek.Despatch)
@Html.HiddenFor(model => model.growWeek.FinishedDuration)
@Html.HiddenFor(model => model.growWeek.FinishedSite)
@Html.HiddenFor(model => model.growWeek.GapUpHandSite)
@Html.HiddenFor(model => model.growWeek.GapUpMCSite)
@Html.HiddenFor(model => model.growWeek.GerminationDuration)
@Html.HiddenFor(model => model.growWeek.GerminationSite)
@Html.HiddenFor(model => model.growWeek.Germinator)
@Html.HiddenFor(model => model.growWeek.GerminatorDuration)
@Html.HiddenFor(model => model.growWeek.GerminatorSite)
@Html.HiddenFor(model => model.growWeek.GProfileNo)
@Html.HiddenFor(model => model.growWeek.GrowWks1)
@Html.HiddenFor(model => model.growWeek.GrowWks2)
@Html.HiddenFor(model => model.growWeek.GrowWks3)
@Html.HiddenFor(model => model.growWeek.GrowWks4)
@Html.HiddenFor(model => model.growWeek.GrowWks5)
@Html.HiddenFor(model => model.growWeek.OrderWK)
@Html.HiddenFor(model => model.growWeek.PreGapDuration)
@Html.HiddenFor(model => model.growWeek.PreGapSite)
@Html.HiddenFor(model => model.growWeek.PrickOut)
@Html.HiddenFor(model => model.growWeek.PrickOutSite)
@Html.HiddenFor(model => model.growWeek.Priority)
@Html.HiddenFor(model => model.growWeek.ProdGrp)
@Html.HiddenFor(model => model.growWeek.ProdSeries)
@Html.HiddenFor(model => model.growWeek.ProdSeriesDetail)
@Html.HiddenFor(model => model.growWeek.ProductionGrowProfile)
@Html.HiddenFor(model => model.growWeek.RangeUpdateFlag)
@Html.HiddenFor(model => model.growWeek.Rooting_GermAssess)
@Html.HiddenFor(model => model.growWeek.SiteGrown)
@Html.HiddenFor(model => model.growWeek.SiteRange)
@Html.HiddenFor(model => model.growWeek.SiteSown)
@Html.HiddenFor(model => model.growWeek.Topping)
@Html.HiddenFor(model => model.growWeek.ToppingCode)
@Html.HiddenFor(model => model.growWeek.Transplant)
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.WksToDesp, "Weeks to despatch")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.WksToDesp, null, new { @class = "form-control", @placeholder = "Weeks to despatch" })
@Html.ValidationMessageFor(p => p.growWeek.WksToDesp, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.GapUp, "Gap up")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.GapUp, null, new { @class = "form-control", @placeholder = "Gap up" })
@Html.ValidationMessageFor(p => p.growWeek.GapUp, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Pinch1, "Pinch1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Pinch1, null, new { @class = "form-control", @placeholder = "Pinch1" })
@Html.ValidationMessageFor(p => p.growWeek.Pinch1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Pinch2, "Pinch2")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Pinch2, null, new { @class = "form-control", @placeholder = "Pinch2" })
@Html.ValidationMessageFor(p => p.growWeek.Pinch2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space1, "Space1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space1, null, new { @class = "form-control", @placeholder = "Space1" })
@Html.ValidationMessageFor(p => p.growWeek.Space1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space2, "Space2")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space2, null, new { @class = "form-control", @placeholder = "Space2" })
@Html.ValidationMessageFor(p => p.growWeek.Space2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space3, "Space3")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space3, null, new { @class = "form-control", @placeholder = "Space3" })
@Html.ValidationMessageFor(p => p.growWeek.Space3, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Check1, "Check1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Check1, null, new { @class = "form-control", @placeholder = "Check1" })
@Html.ValidationMessageFor(p => p.growWeek.Check1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Edit" class="btn btn-default" />
</div>
</div>
</form>
}
</div>
</div>
</div>
</div>
我到处都在检查,这个根本没有打电话……有什么想法吗?
P.S。 ...这可能是相关的,因此,在此页面上,(在呈现此部分的索引上)我的页脚正在代码中呈现在我页面中间的某个位置..
这没有多大意义,但就是这样。问题是每次我为那个 table 生成值时,它都会出于某种原因删除它后面的部分视图(如果有人能理解这种行为并且可以解释,请这样做。)
所以,我的这个页面的索引曾经是这样的:
<div class="tab-content col-md-9 col-lg-9 growProfilePage">
<div class="col-md-12 col-lg-12">
<div class="col-md-4">
@{ Html.RenderPartial("ListGrowProfiles");}
</div>
<div class="col-md-8">
@{ Html.RenderPartial("ListGrowWeeks");}
@{ Html.RenderPartial("EditGrowWeek");}
</div>
</div>
</div>
现在看起来像这样:
<div class="tab-content col-md-9 col-lg-9 growProfilePage">
<div class="col-md-12 col-lg-12">
@{ Html.RenderPartial("EditGrowWeek");}
<div class="col-md-4">
@{ Html.RenderPartial("ListGrowProfiles");}
</div>
<div class="col-md-8">
@{ Html.RenderPartial("ListGrowWeeks");}
</div>
</div>
</div>
一切正常(奇怪的是,在其他页面上它仍然像以前一样,在列表之后进行编辑并且它像那样工作)。