ViewData.Model.Property

Last post 06-04-2008 4:18 AM by pure.krome. 2 replies.

Sort Posts:

  • ViewData.Model.Property

    06-04-2008, 12:26 AM
    • Member
      point Member
    • Yarini
    • Member since 01-29-2006, 8:40 PM
    • Posts 1

    I using the ViewData.Model.Property to access ViewData elements but it doesn´t work. Who is the provider of this funcionality? Does this funcionality is implemented in Preview 3 Refresh?

    --Yarini

  • Re: ViewData.Model.Property

    06-04-2008, 3:31 AM
    • Contributor
      4,446 point Contributor
    • levib
    • Member since 07-23-2007, 11:50 PM
    • Redmond, WA
    • Posts 776
    • AspNetTeam

    Certain overloads of Controller.View() take a model as a parameter (you can get the full list via IntelliSense, Reflector, or the Object Browser).  If you pass a model object into these methods, that object will be available on the ViewData.Model property in your view page.  Note that if you want to access your model as a strongly-typed object rather than just an object, you should make your view page inherit from ViewPage<TModel> rather than just ViewPage.

    If you tried these and are still experiencing a problem, please post your controller code, view page code, and the error message that you're getting.  We'll be able to be of more help if you provide that information.

  • Re: ViewData.Model.Property

    06-04-2008, 4:18 AM
    • Member
      532 point Member
    • pure.krome
    • Member since 05-28-2006, 12:45 AM
    • Melbourne, Australia
    • Posts 348

    it works perfectly for me mate :)

     I make sure my view is strongly typed and then, when i pass in the instance of the strongly typed viewdata, into that view, the ViewData.Model property is now populated with my special awesome data.

    need code to help explain? just post if you do.

    :: Never underestimate the predictability of stupidity ::
Page 1 of 1 (3 items)