4

I've done a lot of C# programming but I haven't touched much web until recently. One thing I've been struggling a little bit with, and really think there must be a better way I don't know about, is the right(a few of the better ways?) way to send the data in a form to a server.

I'm using MVC4 / C #, and I'm working on an html form that will be at least 18 inputs, some with multiple selections, and the ability for users to click 'add another' to a certain spot, and could make the amount of input fields 30+.

Is there any neat way to package this into some sort of javascript object, and receive it as a object in c#?

I would prefer to not do a post with the form, since I want to use AJAX and not have the page refresh.

In the only other form I have done so far in this project, there was about 6 inputs, but each one was optional. I built a queryurl and used jquery. Just this seemed like more of a pain than it needed to be and it's much smaller.

$.get(apiLink, function (response) {
        $("#SearchResults").html(response);
    });

1 Answer 1

2

You can create a JSON object with all the inputs you have, and then parse it on your controller using JSON.NET

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.