Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
645 views
in Technique[技术] by (71.8m points)

asp.net <%$ ... %> syntax

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...