I'm new to MVC2 in ASP.NET/C#, so please forgive me if I misunderstand something. I have code similar to this in my Controller:
var singleInstance = new Person("John");
ViewData["myInstance"] = singleInstance;
return View();
So in my view, Index.aspx, I want to be able to reference members in that object. For example, Person has a member called Name, which is set in the constructor. In the view I want to get Person.Name from what is stored in the ViewData object. Ex.:
<%= ViewData["myInstance"].name %>
That doesn't work. The only real workaround I've found is to do something like this:
<% var thePerson = ViewData["myInstance"];
print (or whatever the method is) thePerson.Name;
%>
Any help would be much appreciated... This was so much easier in PHP/Zend Framework... sigh