ASP.NET Expression Builders - Part 1
Some linkage first:
- Use ExpressionBuilder To Avoid "Server tags cannot contain <% ... %> constructs"
- The CodeExpressionBuilder
- skmExpressionBuilders - A Suite of Custom Expression Builder Classes
- Using Expression Builders in ASP.NET
Put basically, expression builders allow you to "intercept" the ASP parser before it starts actually processing server tags and thus insert code into the C# that's generated by the ASP.net markup, so you can set the values of properties in the ASP.net markup, rather than doing it in the Page_Load, or similar, method.
<asp:Literal runat="server" Text="<%$ MyExpressionBuilder: my.key.that.gets.handled %>
In a product I'm working on I'm planning on using it to implement database backed localisation for UI strings. The current solution has all pages inherit from a base page that provides an abstract "SetLocalisedStrings" method which gets called and is responsible for setting all the relevant ".Text" properties of various controls. Clunky, and it separates the localisation keys from the actual controls making it hard to match-up what goes where.