dynamic

Building Expression Evaluator with Expression Trees in C# – Improving the Api

This post is part of a series about building a simple mathematical expression evaluator. For previous posts and full source code see Table of Contents. Introduction In previous part we added support for variables but it has a big disadvantage: values of the variables are bound by position and not by name. This means that you should pass values for the variables in the same order as they appear in the expression. For example the following test will fail:

Dynamic ViewState in ASP.Net WebForms – Part 2

In previous post I showed an approach combining DynamicObject with ViewState for accessing ViewState members using dynamic properties instead of string indexes. However that approach had some disadvantages: It is tied some a concrete base page class. It does not have all the properties/methods of StateBag class Mixing ViewState and ViewBag can be confusing for new developers. In order to overcome these issues I made several changes to the DynamicViewState class.

Dynamic ViewState in ASP.Net WebForms

If you have worked with ASP.Net MVC 3 you are probably aware of ViewBag property which allows you to pass data from Controller to View by using dynamic properties instead of hard coding strings. While the properties still are not strongly typed and compiler does not check them it can provide an advantage. For example you can avoid casting as it returns dynamic objects. This post will show how to use the same approach in ASP.Net Web Forms for ViewState property giving us a dynamic viewstate class.