Hi @lastcoder ,
public List<AssetsViewModel> objAssets { get; set; }
<input asp-for="objAssets[i].Name" type="hidden" id="hdnat" />
@Html.Hidden("Exam",@Model.objsset[i].AssetName ) //this posts null
@Model.objAsett[i].AssetID</td>
@Model.objAsett[i].AssetName</td>//This presents on the view fine.
Is this the code you copied and pasted, I found that @Model.objAssets
is misspelled, suggest you check the spelling of all objAssets
.
The Html.Hidden
creates a hidden input but you have to specify the name and all the attributes you want to give that field and value. The Html.HiddenFor
creates a hidden input for the object that you pass to it, they look like this:
@Html.Hidden("yourProperty",model.yourProperty);
@Html.HiddenFor(m => m.yourProperty)
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.