Wednesday, 22 November 2017

ViewBag and ViewData


ViewBag :.ViewBag is a dynamic property that takes advantage of the new dynamic features in c# 4.0..Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view..It's life also lies only during the current request..If redirection occurs then it's value becomes null..It doesn't required typecasting for getting data.


ViewData :.ViewData is a dictionary object that is derived from ViewDataDictionary class..ViewData is used to pass data from controller to corresponding view..It's life lies only during the current request..If redirection occurs then it's value becomes null..It's required typecasting for complex data type and check for null values to avoid error.

No comments:

Post a Comment