I'm trying to make the switch from Java to .NET.
I've noticed a number of ASP.NET pages have <%$ sometext %>
in them. Can someone explain what this does in a couple of sentences, or point me to a reference on the syntax?
It's expression builder syntax, and it's used commonly to access settings in the web.config
. Here's an example using expression builder syntax to get a connection string:
ConnectionString="<%$ ConnectionStrings:sqlconnection %>"
Here's a good article that explains all of the inline expressions:
http://support.microsoft.com/kb/976112
The expression builder is used to set values of control properties based on the information that is contained in an application's configuration or resource files. The following is the basic syntax of the expression builder:
<%$ Expression Prefix: Expression Value %>
The dollar sign ($
) indicates to ASP.NET that the following expression is an expression builder. The expression prefix defines the kind of expression, such as AppSettings, ConnectionStrings, or Resources. Additionally, you can create and define your own expression builder. The expression value that follows the colon (:
) is what ASP.NET will actually use as the value of a certain property.
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