1 Replies - 261 Views - Last Post: 01 August 2017 - 07:05 PM

#1 aidenkael  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 59
  • View blog
  • Posts: 275
  • Joined: 22-October 13

Post form results to controller MVC 5 Core 1.1

Posted 01 August 2017 - 05:41 PM

All, having a bit of trouble with my MVC site I am spinning up. I need to post data back to the Controller. The data would be captured in the following form:

<div class="row">
    <form action="/SubmitRequest">
        <table>
            <tbody>
                <tr>
                    <td>
                        String
                    </td>
                    <td>
                        <input name="string1" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        String 2
                    </td>
                    <td>
                        <input name="string2" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Bool Val
                    </td>
                    <td>
                        <input name="chk1" type="checkbox" />
                    </td>
                </tr>
            </tbody>
        </table>
    </form>



When my form executes, it needs to hit a controller such as:
[HttpPost]
        public IActionResult SubmitRequest(ViewModel vm)
        {
            //do things
            return View();
        }



I have access to the jquery libraries, and I believe I need to post json data back. How can I do this? The ViewModel is a 1:1 match of the objects (string String, string String2, bool Chk1, all required).

Is This A Good Question/Topic? 0
  • +

Replies To: Post form results to controller MVC 5 Core 1.1

#2 aidenkael  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 59
  • View blog
  • Posts: 275
  • Joined: 22-October 13

Re: Post form results to controller MVC 5 Core 1.1

Posted 01 August 2017 - 07:05 PM

Fixed this by following the first answer here on stack overflow. Will post code soon!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1