Browsing Tag »dynamic«

Dynamic Methods in View Data

August 2, 2010

In ASP.NET MVC 3 Preview 1 , we introduced some syntactic sugar for creating and accessing view data using new dynamic properties. Sugar, it’s not just for breakfast. Within a controller action, the ViewModel property of Controller allows setting and accessing view data via property accessors that are resolved dynamically at runtime. From within a view, the View property provides the same thing ( see the addendum at the bottom of this post for why these property names do not match ). Disclaimer This blog post talks about ASP.NET MVC 3 Preview 1, which is a pre-release version. Specific technical details may change before the final release of MVC 3. This release is designed to elicit feedback on features with enough time to make meaningful changes...(read more)

Passing anonymous objects to MVC views and accessing them using dynamic

December 19, 2009

First, I’ll start with a little disclaimer: this post is not about whether using dynamic is better/worse than static typing. Instead, it’s about making it more convenient to use dynamic if you choose to go that route . Clearly, some people dislike dynamic, as you can see in the comments in that post from Phil Haack , and for the most part, all the key arguments for/against have been made. So anyway, let’s proceed… Recently, a few people have experimented with extending their view pages from ViewPage<dynamic>. The idea is to then be able to access model data using the more convenient dynamic syntax. e.g. check out this thread on StackOverflow, as well as Phil’s post I mention above. One limitation that people are hitting is that you can...(read more)