/
ExpressionPrefixAttribute.xml
151 lines (135 loc) · 9.41 KB
/
ExpressionPrefixAttribute.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<Type Name="ExpressionPrefixAttribute" FullName="System.Web.Compilation.ExpressionPrefixAttribute">
<TypeSignature Language="C#" Value="public sealed class ExpressionPrefixAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ExpressionPrefixAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.Web.Compilation.ExpressionPrefixAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ExpressionPrefixAttribute
Inherits Attribute" />
<TypeSignature Language="F#" Value="type ExpressionPrefixAttribute = class
 inherit Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class ExpressionPrefixAttribute sealed : Attribute" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Specifies the prefix attribute to use for the expression builder. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Compilation.ExpressionPrefixAttribute> class is used at design time with expressions that are not defined in the configuration file. Use the <xref:System.Web.Compilation.ExpressionPrefixAttribute.ExpressionPrefix%2A> property to get the name of the prefix that is associated with the <xref:System.Web.Compilation.ExpressionPrefixAttribute> object. An expression builder looks for any statements with the following form:
`<%$ [expressionPrefix]:[expressionValue] %>`
Then the expression builder, based on the prefix of the expression, generates code for the property assignment. The `expressionPrefix` parameter refers to a configured expression builder, which is defined in the configuration file or through an <xref:System.Web.Compilation.ExpressionPrefixAttribute> object.
## Examples
The following code examples demonstrate how to use the <xref:System.Web.Compilation.ExpressionPrefixAttribute> class. The attribute is applied to a custom expression builder that implements the <xref:System.Web.Compilation.ExpressionBuilder> abstract class. This implementation of <xref:System.Web.Compilation.ExpressionBuilder> returns an evaluated statement that is passed to the expression. To run this example, you must first register the custom expression builder in the Web.config file. The first code example demonstrates how to register the custom expression builder in the Web.config file.
```
<configuration>
<system.web>
<compilation>
<expressionBuilders>
<add expressionPrefix="MyCustomExpression"
type="MyCustomExpressionBuilder"/>
</expressionBuilders>
</compilation>
</system.web>
</configuration>
```
The second code example demonstrates how to reference the expression in an .aspx file.
```
<asp:Label ID="Label1" runat="server"
Text="<%$ MyCustomExpression:Hello, world! %>" />
```
The third code example demonstrates how to develop a customized expression builder by deriving from <xref:System.Web.Compilation.ExpressionBuilder>. To run this code example, you must place the class in the App_Code folder.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Compilation.ExpressionBuilder/CS/MyExpressionBuilder.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Compilation.ExpressionBuilder/VB/MyExpressionBuilder.vb" id="Snippet1":::
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.Design.ExpressionEditor" />
<altmember cref="T:System.Web.UI.Design.ExpressionEditorSheet" />
<altmember cref="T:System.Web.UI.Design.AppSettingsExpressionEditor" />
<altmember cref="T:System.Web.Compilation.ExpressionBuilder" />
<altmember cref="P:System.Web.Configuration.ExpressionBuilder.ExpressionPrefix" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ExpressionPrefixAttribute (string expressionPrefix);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string expressionPrefix) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Compilation.ExpressionPrefixAttribute.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (expressionPrefix As String)" />
<MemberSignature Language="F#" Value="new System.Web.Compilation.ExpressionPrefixAttribute : string -> System.Web.Compilation.ExpressionPrefixAttribute" Usage="new System.Web.Compilation.ExpressionPrefixAttribute expressionPrefix" />
<MemberSignature Language="C++ CLI" Value="public:
 ExpressionPrefixAttribute(System::String ^ expressionPrefix);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="expressionPrefix" Type="System.String" />
</Parameters>
<Docs>
<param name="expressionPrefix">The prefix of the current <see cref="T:System.Web.Compilation.ExpressionBuilder" />.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.Compilation.ExpressionPrefixAttribute" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.Compilation.ExpressionPrefixAttribute.%23ctor%2A> constructor to initialize an instance of the <xref:System.Web.Compilation.ExpressionPrefixAttribute> class using a prefix identifier. The <xref:System.Web.Compilation.ExpressionPrefixAttribute.%23ctor%2A> is the parameterless constructor for the <xref:System.Web.Compilation.ExpressionPrefixAttribute> class.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="expressionPrefix" /> is null or an empty string ("").</exception>
<altmember cref="T:System.Web.UI.Design.ExpressionEditor" />
<altmember cref="T:System.Web.UI.Design.ExpressionEditorSheet" />
<altmember cref="T:System.Web.UI.Design.AppSettingsExpressionEditor" />
<altmember cref="T:System.Web.Compilation.ExpressionBuilder" />
<altmember cref="P:System.Web.Configuration.ExpressionBuilder.ExpressionPrefix" />
</Docs>
</Member>
<Member MemberName="ExpressionPrefix">
<MemberSignature Language="C#" Value="public string ExpressionPrefix { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string ExpressionPrefix" />
<MemberSignature Language="DocId" Value="P:System.Web.Compilation.ExpressionPrefixAttribute.ExpressionPrefix" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property ExpressionPrefix As String" />
<MemberSignature Language="F#" Value="member this.ExpressionPrefix : string" Usage="System.Web.Compilation.ExpressionPrefixAttribute.ExpressionPrefix" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ ExpressionPrefix { System::String ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the prefix value for the current <see cref="T:System.Web.Compilation.ExpressionBuilder" /> object.</summary>
<value>The expression prefix for the configured <see cref="T:System.Web.Compilation.ExpressionBuilder" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.Compilation.ExpressionPrefixAttribute.ExpressionPrefix%2A> property to retrieve the name of the prefix that is associated with a given attribute.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.Design.ExpressionEditor" />
<altmember cref="T:System.Web.UI.Design.ExpressionEditorSheet" />
<altmember cref="T:System.Web.UI.Design.AppSettingsExpressionEditor" />
<altmember cref="T:System.Web.Compilation.ExpressionBuilder" />
<altmember cref="P:System.Web.Configuration.ExpressionBuilder.ExpressionPrefix" />
</Docs>
</Member>
</Members>
</Type>