WHATT'S THE DIFFERENCE BETWEEN VIEWDATA AND VIEWBAG?

Pawan Shukla

Total Post:36

Points:260
Posted by  Pawan Shukla
 1072  View(s)
Ratings:
Rate this:

I saw the ViewBag in MVC 3. How's that different than ViewData in MVC 2?

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: What's the difference between ViewData and ViewBag?

    ViewData & ViewBag objects


    ·   ViewData


    ViewData is a dictionary object that you put data into, which then becomes available to the view. ViewData is a derivative of the ViewDataDictionary class, so you can access by the familiar "key/value" syntax.

    ·    ViewBag

    The ViewBag object is a wrapper around the ViewData object that allows you to create dynamic properties for the ViewBag.

      Modified On Apr-09-2018 01:55:50 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!