3

I am using MVC. I have a view model which contains a Business object.

I need to post this Business Object back to a controller action using AJAX.

For now, I am using Url.Action function to create my request Url for AJAX and pass the Business Object id as a request parameter to the action. I then have to retrieve the object from the database to use it.

Is there a way (using Json) to pass this object as an Object? The object is shown below

public class BusinessObject : BaseBusinessObject
{
    public virtual string Id { get; set; }
    public virtual IDictionary Data { get; set; }
    public virtual IDictionary Collections { get; set; }
}

The controller action should ideally have a deifinition like ...

public ActionResult DOThis(BusinessObject bo) {}

2 Answers 2

1

What you are looking for is FORM Binding, there are lot of resources available, This link gives you some insight.

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

1 Comment

Custom Binding is very helpful to bind your forms to some very complex models.
0

You should use the JsonResult for going from the server to the client. http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=399#start

The DefaultModelBinder will take care of the binding to the server. There is also a section in this page talking about calling from JQuery to the server and getting back the JsonResult.

Hope this helps!

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.