Custom Expression Builders in ASP.net

As a SharePoint developer, I am unfortunately stuck with the WebForms model of ASP.net since SharePoint 2007 does not support ASP.net MVC. Well, WebForms is not THAT bad really, but it can get really messy very fast, especially for simple databinding stuff – lblTitle.Text = bla.fasel; lblWhatever.Text = eek.boo; etc.

Now, there is a truly hidden Gem: Expression Builders. Using <%$ MyExpressionBuilder.Property %>, I can directly do this type of DataBinding in the .aspx file without requiring code behind. I have not yet tested if it works if you have not set AllowServerSideScript=”true” in the PageParserPaths tag of SharePoint’s web.config (something that I would always avoid).

The full article about Custom Expression Builders can be found over at Phil Haack’s blog, along with an explanation how this is different from <%= %>.

Leave a Reply

Your email address will not be published. Required fields are marked *