I have a javascript object, obj , which is passed to the mvc action via $ .post () as follows:
var obj = { Items: [{ Text: "", Value: { Property1: "", Property2: "" }, { Text: "", Value: { Property1: "", Property2: "" }] }; $.post('MyAction', obj, function() {});
the action signature is as follows:
public ActionResult MyAction(FormCollection collection) { }
I need to build an object from FormCollection , however I ran into a problem when the keys are in the form:
"Items[0][Text]" "Items[0][Value][Property1]" "Items[0][Value][Property2]" "Items[1][Text]" "Items[1][Value][Property1]" "Items[1][Value][Property2]"
I am wondering if there is a clean way to create the desired C # object from the given FormCollection . I understand that I can change the signature of the action method to take the type of object that interests me, but this presented its own problems.
Omer bokhari
source share