如果您将其保存在隐藏字段的页面上,则可以在回发时获取查询字符串参数。如果编辑形状取决于这个参数,它会有点困难。
司机:
protected override DriverResult Editor(PerformerPart part, dynamic shapeHelper)
{
return Editor(part, null, shapeHelper);
}
司机:
protected override DriverResult Editor(PerformerPart part, IUpdateModel updater, dynamic shapeHelper)
{
var model = new PerformerPartEditViewModel();
if (updater != null)
{
if (updater.TryUpdateModel(model, Prefix, null, null))
{
// update part
}
}
else
{
model.StrId = _wca.GetContext().HttpContext.Request.QueryString["id"]; // if you save id in your part that you can also try get it from the part
}
if (string.IsNullOrEmpty(model.StrId))
{
// populate model with empty values
}
else
{
// populate model with right values
}
return ContentShape("Parts_Performer_Edit", () => shapeHelper.EditorTemplate(
TemplateName: "Parts/Performer",
Prefix: Prefix,
Model: model
));
}
看法
@model Smth.ModuleName.ViewModels.PerformerPartEditViewModel
@Html.HiddenFor(m => m.StrId)