Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • CodeMaster2008 151 posts 184 karma points
    Dec 11, 2012 @ 22:30
    CodeMaster2008
    0

    How can I access ViewData() or TempData() from a view?

    When working with a view today I tried to access a value from ViewData("myValue") and it just doesn't work.
    I got an compilation error:

    The name 'TempData' does not exist in the current context

    So, how can I access it from a view or partial view on Umbraco (4.11.1)

  • CodeMaster2008 151 posts 184 karma points
    Dec 14, 2012 @ 00:52
    CodeMaster2008
    0

    Before anything let me say that I tried to delete this post but I couldn't.
    The question looks dummy enough but I though there was something different about MVC on umbraco until I realize that after hours porting some code from the evil Dr. VB.NET to C#, I started writing:

    ViewData("MyKey") 

    Which is the VB.NET syntax, Instead of:

    ViewData["MyKey"]

    And that's the reason for the message: The name 'ViewData' does not exist in the current context.
    Anyways, I don't think it's helpfull so to any moderators out there, feel free to delete this post. 

Please Sign in or register to post replies

Write your reply to:

Draft