I have used ExpressionBuilders here and there within my asp.net markup to return simple data types.
Does anyone have any ideas how an ExpressionBuilder might be used to wire up an event inline? Or can ExpressionBuilders only return literals?
I would like to wire up the OnLoad event (or any event) by creating an ExpressionBuilder (named AutoBind in my example). Any ideas if this can be done?
<asp:DropDownList ID='DropDownList1' runat='server' DataSource='<%# GetRecords() %>' DataTextField='Name' DataValueField='ID' OnLoad='<%$ AutoBind: this.DataBind() %>' />
Sam is correct. Expressions can only be set on properties, it will not wire an event. I got ‘close’ by doing this with the expression builder.
In the mark of the page you would write something like this…
The problem is that the compiler will generate this.
It’s essentialy ‘converting’ the delegate to a string and in reality you want the compiler to do this…