Home » c# » c# – Page with multiple partial views post data-Exceptionshub

c# – Page with multiple partial views post data-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I need to have a generic parent view model

Parent Model :

List<string> ProviderType (dropdown list) 
Object ProviderObject (can we have this generic object to hold the partial view data)

Partial Model:

String name 
String description

Depending on the selected “ProviderType” (which is a drop down) I need to populate a partial view and post data from both parent and partial view on save.

Can I have a generic object in parent model ProviderObject that will be updated to the type of partial view loaded and posted to controller and on the controller I can type cast it with the required object depending on provider type ?

I am able to load the partial view when the dropdown is changed using ajax call. But how to pass the combined data of the parent and partial view to the controller. Or should I have separate controller methods for each of the partial views ?

How to&Answers: