I have a little different view of the common views in my project. It's using Ajax.StartForm
like the all others. But in this case I just want to send a JavaScript object parsed in JSON, and not the value of the fields of my form.
To illustrate, I have imagine this steps: On this form, when submit button was pressed, the default submit event would be intercepted and a JavaScript object would be created - gathering values from some custom widgets - to be sent to the Action. Then that object would be sent like data: JSON.stringify(that_object)
like on jQuery.ajax
.
The problem is that I don't want to use jQuery.ajax
, I want to use MVC's Ajax.StartForm
because of some functions and validations automatically activated by my application to it.
There's a way accomplish that behaviour?
If that was not possible, I'm afraid I will be forced to store that object parsed in JSON as a string in a hidden field in order to submit it.
UPDATE:
This is my ViewModel:
public class ProcessWizardViewModel
{
public long ProcessId { get; set; }
public List<long> ProcessIds { get; set; }
public List<ProcessItemWizardViewModel> Items { get; set; }
public ProcessWizardViewModel()
{
ProcessIds = new List<long>();
Items = new List<ProcessItemWizardViewModel>();
}
}
public class ProcessItemWizardViewModel
{
public long Type { get; set; }
public bool Dependence { get; set; }
public long ProcessCultureId { get; set; }
public ProcessItemWizardViewModel() { }
}
ProcessIds
comes from a grid with checkbox selection and Items
comes from a tree view with checkbox selection.