I saw an example of using Expression Builders, and creating your own Custom Expression Builder Classes here:
http://aspnet.4guysfromrolla.com/articles/022509-1.aspx
However, I fail to see the value in using this approach. It doesn't seem much easier than programmatically setting values in your code behind.
As far as I can tell, the only thing you can do with them is set properties. Maybe they would be useful for setting defaults on certain controls?
Can anyone shed light on where this ASP.NET feature becomes powerful?
Custom Expressions are handy if you care about ViewState (you should). See TRULY Understanding ViewState.
We are using a custom expression builder to localize our application. E.g. the markup looks like this:
<asp:LinkButton Text="<%$ Str:SomeString %>" ... />
The expression builder reads a string with the ID SomeString from a resource file (taking into account the current user's language preferences) and assigns it to the Text property of the LinkButton.
This is quite flexible: we can add languages by simply copying a resource file into the application directory. And if a customer wants to have a different text for that linkbutton, he just adds his custom string to the resource files and changes the string-ID in the expression builder (without having to change the code-behind).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With