Asp.net : table that i want to collect values from and add to empty input to a form

Daniel 156 Reputation points
2021-07-10T20:14:44.19+00:00

I have an asp.net core MVC app which I have a form with some fields in a table.

On the same page, with JavaScript, I generate rows and cells to an existing table that is not in the same as my form.

On post in my form I want to collect the values generated from my javascript code and the other table and pass this along with my post as a new list.

Can I create a hidden input inside my form and for each over the JavaScript populated table? Or should it be done in another way?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,612 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,010 questions
{count} votes

Accepted answer
  1. Viorel 118K Reputation points
    2021-07-11T13:42:38.77+00:00

    Maybe collect the data from your rows using JavaScript and obtain a JSON string, which can be put to your hidden field. Then use the System.Text.Json package on client side (added using “Manage NuGet Packages”) to convert the string to objects.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.