asp.net <%$ ... %> 语法

标签 asp.net

我正在尝试从 Java 切换到 .NET。

我注意到许多 ASP.NET 页面都有 <%$ sometext %>在他们中。有人可以用几句话解释一下它的作用,或者给我指出语法引用吗?

最佳答案

它是表达式生成器语法,通常用于访问 web.config 中的设置。以下是使用表达式生成器语法获取连接字符串的示例:

ConnectionString="<%$ ConnectionStrings:sqlconnection %>"

这是一篇很好的文章,解释了所有内联表达式:
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.

关于asp.net <%$ ... %> 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7934160/

相关文章:

c# - 无法连接远程服务器(Web 服务)

javascript - 如何使用 Aurelia + .Net Core + IIS Web 应用程序获取正确的 url

asp.net - 如何在 ASP.NET MVC 5.2.3 应用程序中的其他位置获取 IAppBuilder 的实例?

c# - C#问题,向现有数据表添加新行

c# - 状态设计模式用户界面

html - 在程序运行html时添加到div的高度

c# - ASP.NET 5/MVC 6 控制台托管应用程序

c# - 必须在 (MVC3 + MVC4) 环境中打开 ASP.NET MVC3 项目

asp.net 身份不记名 token 在 20 分钟后过期

javascript - 从 aspx 页面中提取 svg 元素的代码?