Different references of server side code

Code enclosed by <% ... %> is just executed, while expressions that include an equal sign, <%= ... %>, are evaluated and the result is emitted as content. Therefore <%="Hello World" %> renders the same thing as the C# code <% Response.Write("Hello World"); %>.

ASP.NET 2.0 adds a new declarative expression syntax for substituting values into a page before the page is parsed. This is useful for substituting connection string values or application settings defined in a Web.config file for server control property values. It can also be used to substitute values from a resource file for locaization.

Benifits of Expression handlers

You can avoid writing lengthy code to set property values at run time. Expression builders allows to include dynamic information using one declarative statement.

A single Expression builder can be referenced across multiple pages. All changes to expression can be made at a central location. Ex: Expression builder for connection strings.

Expression builders are extensible. You can define custom Expressions that call your custom expression handler to return a value that will be substituted at run time.

Expression builder syntax is language neutral. You can same syntax across universal .Net languages

Expression builder offers both design time support as well as parse-time support. Design time support means you can built expression using Expression Dialog when accessed using properties window of control.

Comments

Popular Posts