I have View Model with inner ViewModel Address propery.
public class CommonViewModel{
public AddressViewModel PreviouslyAddress { get; set; }
}
And Address:
[Serializable]
public class AddressViewModel
{
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string Prefix { get; set; }
public string ZipCode { get; set; }
}
I want to serialize it, and get deseriliazed on POST.
I use:
@Html.Serialize("PreviouslyAddress", Model.PreviouslyAddress)
But in all examples they use Attribute DeserializeAttribute which can be implemented only in method parameters.
Example enter link description here
EDITED
How can I do it without create custom bunding and send part of my model as parameter.
[HttpPost]
public ActionResult Register([DeserializeAttribute] AddressViewModel user, FormCollection userForm)
{
TryUpdateModel(user, userForm.ToValueProvider());
For example, if it is possible I want something like this:
[HttpPost]
public ActionResult Register(CommonViewModel model)
{
TryUpdateModel(user, userForm.ToValueProvider());
public class CommonViewModel{
[DeserializeAttribute]
public AddressViewModel PreviouslyAddress { get; set; }
}
You could use the
MvcSerializerclass to deserialize manually some string back into a model: