It appears that creating a public property (that returns an anonymous object) in your code-behind of type 'dynamic' and exposing it to your aspx page converts the variable to type 'object'. Is this correct? Anytime I try to do this I get an exception saying
'object' does not contain a definition for val1
Here is an example:
public dynamic showMe
{
get
{
return new
{
val1 = 5,
val2 = "This is val2",
val3 = new List<int>(){1,2,3,4,5}
};
}
}
On the ASPX page I have:
<h2><%= showMe.val1 %></h2>
and with this image you can see that on my aspx page it does indeed know about the properties inside the dynamic object.
Does anyone know of a way to refer to properties of anonymous objects via embedded code, or is it simply not possible with the type system? Thanks.