Wednesday, June 15, 2011

ASP.NET Expression Builders

http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx



[ExpressionPrefix("Code")]
public class CodeExpressionBuilder : ExpressionBuilder {
    public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, 
       object parsedData, ExpressionBuilderContext context) {
        return new CodeSnippetExpression(entry.Expression);
    }
}
<compilation debug="true">
  <expressionBuilders>
    <add expressionPrefix="Code" type="Infinity.Web.Compilation.CodeExpressionBuilder"/>
  </expressionBuilders>
</compilation>
And to see it in action:
<asp:CheckBox id="chk1" runat="server" Text="<%$ Code: DateTime.Now %>" />

No comments:

Post a Comment