Method call with void return type in data binding expression

Is it possible to call the void return method in an expression to bind data? (To set a global variable, for example.)
The following does not compile:

<%# setCurrent(false) %>  // Error: Cannot implicitly convert type 'void' to 'object'

I could change the return type of the method (for example, return a null object to it), but this will cheat.

+3
source share
2 answers

The whole point of data binding is that a value is returned for display. (hence the error)

Just return an empty string :)

0
source

I think putting a semicolon after your statement should make it semantically correct:

setCurrent(false);

This is not a “data binding” as such, but it works.

0

All Articles