I've got a page model that has an abp-tabs defined as
}
<abp-dynamic-form abp-model="Item" asp-page="/Anagrafiche/Clienti/EditModal">
<abp-modal size="Large">
<abp-modal-header title="@L["Update"].Value"></abp-modal-header>
<abp-modal-body>
<abp-tabs>
<abp-tab title="Generale">
<abp-form-content />
</abp-tab>
<abp-tab title="Scontistiche">
@{
await Html.RenderPartialAsync("_Scontistiche");
}
</abp-tab>
<abp-tab title="Clienti con stesso comune">
</abp-tab>
<abp-tab title="Clienti con stessa provincia">
Clienti con stessa provincia
</abp-tab>
</abp-tabs>
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>
I've defined the _Scontistiche.cshtml as
public class _ScontisticheModel : xxxPageModel
{
public _ScontisticheModel()
{
}
public void OnGet()
{
}
}
But when I run it I got
System.InvalidOperationException: 'The model item passed into the ViewDataDictionary is of type 'xxx.Web.Pages.Anagrafiche.Clienti.EditModalModel', but this ViewDataDictionary instance requires a model item of type 'xxx.Web.Pages.Anagrafiche.Clienti._ScontisticheModel'.'
What am I doing wrong? Thanks
CodePudding user response:
The error is saying you are passing the wrong model to your partialview. Looking at the code, this error is indeed correct. The following line is causing the issue.
@{
await Html.RenderPartialAsync("_Scontistiche");
}
By default the model of your parent page will be sent to the partial view, unless you define a different model. You can do this by passing a _ScontisticheModel
model like so.
@{
await Html.RenderPartialAsync("_Scontistiche", Item);
}
Considering Item
is the correct model you are referring to. If you don't have a model, you can also pass a new class like so:
await Html.RenderPartialAsync("_Scontistiche", new _ScontisticheModel());