Hi @zola ,
According to your description, I found you directly use data-pdetail="@p_detail
inside the view codes. This will not set the value inside the data-pdetail attribute instead of the type name.
To solve this issue, I suggest you could try to use @JsonSerializer.Serialize(p_detail)
to solve this issue.
More details, you could refer to below codes:
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
@if (Model != null){
@for (int i = 0; i < Model.Count; i++)
{
List<CoreFiveMVC.Controllers.policyDetailsViewModel.Mypolicydetail> p_detail = Model[i].data.myPolicyDetails;
for (int j = 0; j < p_detail.Count; j++)
{
<button class="btn btn-primary s" id="@p_detail[j].polCode" data-pdetail="@JsonSerializer.Serialize(p_detail)">Test @p_detail[j].polCode </button>
}
}
}
Then inside the backend , if you are using the asp.net core , you should add FromBody
to accept the Json format.
More details, you could refer to below codes:
public ActionResult policySummaryPreview([FromBody]List<policyDetailsViewModel.Mypolicydetail> vm)
Result: