The data will only be sent to the surface controller if it's attached to a form element (textbox, dropdown etc). If you need the data sent to the surface controller, one option would be to store the data in a hidden input field
Hi Ben Thank you for helping me.
I generate the list dynamically and ID and name will be different. and I get the following error No parameterless constructor has been defined for this object. Im trying to save content from FormViewModel -> Model
@for(int i = 0; i < Model.Allslopesform.Count(); i++)
{
@Html.CheckBoxFor(m => m.Allslopesform[i].IsOpen)
@Model.Allslopesform[i].SlopeName
}
generated html
<input id="Allslopesform_0__IsOpen" name="Allslopesform[0].IsOpen" type="checkbox" value="true"><input name="Allslopesform[0].IsOpen" type="hidden" value="false"> slope1 ...and so on
The 'No parameterless constructor has been defined for this object' error is usually thrown when a class is being serialised but can't (as it doesn't have a default constructor with no parameters)
Is the type used for the 'Allslopesform' property a custom class and if so, does it have constructors?
Populate a List in Viewmodel gets null when post from View -> Surfacecontroller
Hi I have created a FormViewModel who contains a List.
I populate the List on render and return the model to the partialview.
The properties from list displays in the view, but when i post the FormViewModel back to Surfacecontroller the List is empty.
Can someone point me in right direction.
Thanks /Christina
The data will only be sent to the surface controller if it's attached to a form element (textbox, dropdown etc). If you need the data sent to the surface controller, one option would be to store the data in a hidden input field
Hi Ben Thank you for helping me. I generate the list dynamically and ID and name will be different. and I get the following error No parameterless constructor has been defined for this object. Im trying to save content from FormViewModel -> Model
generated html
The 'No parameterless constructor has been defined for this object' error is usually thrown when a class is being serialised but can't (as it doesn't have a default constructor with no parameters)
Is the type used for the 'Allslopesform' property a custom class and if so, does it have constructors?
Many Thanks For helping me I figured it out, I had to populate an array
/C
is working on a reply...