AppSettingsExpressionBuilder Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves values, as specified in a declarative expression, from the <appSettings>
section of the Web.config file.
public ref class AppSettingsExpressionBuilder : System::Web::Compilation::ExpressionBuilder
public class AppSettingsExpressionBuilder : System.Web.Compilation.ExpressionBuilder
type AppSettingsExpressionBuilder = class
inherit ExpressionBuilder
Public Class AppSettingsExpressionBuilder
Inherits ExpressionBuilder
- Inheritance
The following code example demonstrates how to retrieve an application settings value in a page that is not compiled.
<%@ Page Language="C#" CompilationMode="Never" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Noncompiled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Welcome to the
<asp:Literal ID="Literal1" runat="server"
Text="<%$ AppSettings: thisSeason %>" /> Sale!
</div>
</form>
</body>
</html>
<%@ Page Language="VB" CompilationMode="Never" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Noncompiled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Welcome to the
<asp:Literal ID="Literal1" runat="server"
Text="<%$ AppSettings: thisSeason %>" /> Sale!
</div>
</form>
</body>
</html>
This code retrieves the following expression from the Web.config file.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="thisSeason" value="Fall"/>
</appSettings>
</configuration>
The AppSettingsExpressionBuilder class provides access to values in the <appSettings>
section of the Web.config file. The <appSettings>
section of the Web.config file contains application-specific values in key/value pairs.
An application value is retrieved by assigning an expression of the form
<%$ AppSettings: appSettingsKey %>
to a property in a control declaration. The part of the expression before the colon (:) designates the type of expression to be retrieved, and the part after the colon signifies the key. The preceding expression would retrieve the following value from the Web.config file.
<appSettings>
<add key="appSettingsKey" value="appSettingsValue"/>
</appSettings>
When the page parser encounters an expression with the AppSettings
prefix, it creates an instance of the AppSettingsExpressionBuilder class to handle the expression.
If the expression is encountered in a page that will be compiled, the AppSettingsExpressionBuilder object generates code to retrieve the specified value from the Web.config file. This code is executed during the execution of the generated page class. If the expression is encountered in a page that will not be compiled, the AppSettingsExpressionBuilder object returns the value from the Web.config file when the page is parsed and executed.
App |
Initializes a new instance of the AppSettingsExpressionBuilder class. |
Supports |
Returns a value indicating whether an expression can be evaluated in a page that is not compiled. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Evaluate |
Returns a value from the |
Get |
Returns a value from the |
Get |
Returns a value from the |
Get |
Returns a code expression that is used to perform the property assignment in the generated page class. |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Parse |
When overridden in a derived class, returns an object that represents the parsed expression. (Inherited from ExpressionBuilder) |
To |
Returns a string that represents the current object. (Inherited from Object) |
Produkt | Versjoner |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET-tilbakemelding
.NET er et åpen kilde-prosjekt. Velg en kobling for å gi tilbakemelding: