Description:if I need to send multiple models and some parameters to my view what will be the best approach ? one way I know is to use viewbag variable but someone told me that its not a very good approach because it does not provide the intellisense.
So a bit confused which approach can fulfil the requirement
Posted by: Jhon Anthony | Posted on: Oct 12, 2018
4
Now if in your case you still want to stick with the current approach then having the intellisense is not a big deal, you can get the intellisense by casting your ViewBag variable to your model at the top of your view.
But the best approach would be to use the ViewModel,ViewModel is a class just like Model class but it contains some extra properties required only for business process(Specific to that view).
For example following new ViewModel can be created which can contain multiple models and parameters as per the requirement and pass it your view.This way you can access the feature of the model i.e(Validation through DataAnnotation,intellisense etc)
Replied by: Tabish Usman | Replied on: Oct 17, 2018