I have a Settings Action on my Account controller that renders the Settings View.
On the Settings View, I recieve a ViewModel that includes ChangePasswordModel.
Here is the SettingsViewModel:
public class SettingsViewModel
{
public ChangePasswordModel ChangePasswordModel { get; set; }
}
The Settings View recieves
@model XBLTools.Models.SettingsViewModel
The ChangePassword View recieves
@model XBLTools.Models.ChangePasswordModel
The ChangePassword view works OK alone.
How to render the ChangePassword View passing the Model.ChangePasswordModel?
I’ve tried some combinations without success getting different errors:
@Html.RenderPartial("ChangePassword", (XBLTools.Models.ChangePasswordModel)(Model.ChangePasswordModel))
@Html.RenderPartial("ChangePassword", Model.ChangePasswordModel)
@Html.Partial("ChangePassword", (XBLTools.Models.ChangePasswordModel)(Model.ChangePasswordModel))
@Html.Partial("ChangePassword", Model.ChangePasswordModel)
Any ideas?
If it’s null pass in a new instance of ChangePasswordModel:
Or instantiate it in the constructor of SettingsViewModel: