简体   繁体   中英

get html table in asp.net mvc controller without ajax call

I am creating a web in in which I have a table,

<table>
   @foreach (var test in Model.testingdata)
   {
       <tr>
            <td>
                 <input type="hidden" name="testSpan @i" value="@test.ID" />
            </td>
       </tr>
   }
</table>

I want to get the data of this table in my mvc controller without any ajax call

what is a way of getting the data in my controller

I misunderstood in the comments, I thought you were trying to render data rather than post it back to the server.

To do this without javascript or ajax you could post the data as a form.

For this you should wrap your table in a form element. For example

<form action="/post-location" method="post">
  <table> .... </table>
  <input type="submit" value="Submit">
</form>

When you click the submit button it will post the data to the location specified in the 'action' field.

See this example: https://www.w3schools.com/tags/tag_form.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM