Untitled

Random thoughts about everything and nothing

ExpressionBuilder

leave a comment »

While fooling around with my Web.config I stumbled on a nice feature in ASP.NET (2.0): ExpressionBuilder classes.

Basically, these classes let you set control properties through *ahem* expressions.

When the page is parsed, the declarative expressions will be used to retrieve the actual value(s). This done through the ExpressionBuilder class.

The framework ships with three expression builder classes, each accessing different resource settings:

  • AppSettingsExpressionBuilder, allows access to the connection strings stored in section of the configuration file;
  • ConnectionStringsExpressionBuilder, allows access to the application settings stored in section of the configuration file;
  • ResourceExpressionBuilder, allows access to localized resources, typically stored in .resx files located in the App_GlobalResources and App_LocalResources folders.

To actually set these expressions, we don’t need to write it out in the property, but we can use Property Inspector > Data > Expressions.

Now the really nice part is yet to come, we can create our own ExpressionBuilders (both design/run-time support). A good place to start is here and ofcourse your local MSDN documentation.

Written by Michael

March 5, 2006 at 10:51 pm

Posted in .NET, Article

Leave a comment