I have a view "Register Application", containing 20 fields. The user registers. After user registered I have an option for user to update components that were submitted.
for example: view Register has sections "Contact Information" , "Address Information" ...etc currently have 5 sections.
so in the Register view I create a viewmodel @model ViewModels.RegisterVMwith all the fields.
and for edit contact information, I have its own @model ViewModels.ContactInformationVM
Now, here is my question since both views will have the same markup code I decided to create a partial view for Contact Information so I can reuse the markup code and will be able to manage it in one place instead of two places.
So in the Register view
@model ViewModels.RegisterVM
.......
@Html.Partial("~/Views/Shared/widget/_ContactInformation.cshtml", @Model)
and in the Contact Information view I want to reuse this partial view
@model ViewModels.ContactInformationVM`
@Html.Partial("~/Views/Shared/widget/_ContactInformation.cshtml", @Model)
Both views have its own viewmodel and the partial view will only be able to accept one viewmodel
No idea what viewmodel I should declare in the partial view
I know I can just copy the code from the partial view and place in the Register view and in the Contact Information view and it would work and solve the issue.. but was wondering if there a better approach to avoid having same code in multiple files.
I hope it makes sense what I am asking. Thanks for reading.
ContactInformationand use that.