Reputation: 113
Hi am working on a simple form submit in asp.net core 3.1 version. I need to use view model to get data from form. The problem is when I try to submit it, the tax model receives null on controller. Everything seems to be correct but still it receives null.
My viewmodel
My model
My form
My controller
Upvotes: 0
Views: 75
Reputation: 18219
asp.net core bind data with name attribute,try to replace:
<input type="text" asp-for="Tax.TaxName" class="form-control" id="TaxName" placeholder="Tax Name" />
with
<input type="text" name="tax.Tax.TaxName" class="form-control" placeholder="Tax Name" />
Upvotes: 1