Post form field values on event change to ActionResult

40 Views Asked by At

I have a MVC view that has many fields, input, checkboxes, select lists etc. When the user makes a choice in any field I use jQuery to trigger a change event that picks the values in all fields and make a (ajax) post to a ActionResult method (with all the values) which makes a database query and at last a search result is returned.
The values from the html fields are put back into the fields so that the user may continue narrowing down his search.

I find it very error-prone and cumbersome to use JQuery for this. I have taken a look at Angular and React, but these seems bloated if I only need it for above task.

I'm open towards frameworks, nuget packages, programming languages, as long as it fits well with above explanation.

Thanks

1

There are 1 best solutions below

1
Andiih On

This doesn't quite feel right as an approach- if you are posting to .NET with AJAX, why not post to a WEBAPI controller, and get back a Json results set - deal with everything in JavaScript (jQuery). However, I'd still keep the form element wrapper and use that to post to the ActionResult MVC controller method to return a View for no-JS scenarios.