-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
ClientIDMode.xml
138 lines (126 loc) · 10.2 KB
/
ClientIDMode.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
<Type Name="ClientIDMode" FullName="System.Web.UI.ClientIDMode">
<TypeSignature Language="C#" Value="public enum ClientIDMode" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed ClientIDMode extends System.Enum" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.ClientIDMode" />
<TypeSignature Language="VB.NET" Value="Public Enum ClientIDMode" />
<TypeSignature Language="F#" Value="type ClientIDMode = " />
<TypeSignature Language="C++ CLI" Value="public enum class ClientIDMode" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Enum</BaseTypeName>
</Base>
<Docs>
<summary>Specifies how ASP.NET generates the <see cref="P:System.Web.UI.Control.ClientID" /> for a control that can be accessed in client script.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use the <xref:System.Web.UI.ClientIDMode> enumeration when you set the <xref:System.Web.UI.Control.ClientIDMode%2A> property for a control. The value that you assign to the <xref:System.Web.UI.Control.ClientIDMode%2A> property determines how the <xref:System.Web.UI.Control.ClientID%2A> property is generated. The value of the <xref:System.Web.UI.Control.ClientID%2A> property is rendered as the `id` attribute in markup, and it is the value that you use to access the control from client script. The value that you assign to the <xref:System.Web.UI.Control.ClientIDMode%2A> property does not affect the <xref:System.Web.UI.Control.ID%2A> property of the server control, only the `id` attribute of the corresponding HTML element.
The default value of <xref:System.Web.UI.Control.ClientIDMode%2A> for a page is Predictable. The default value of <xref:System.Web.UI.Control.ClientIDMode%2A> for a control is Inherit.
Because the default for controls is Inherit, the default generation mode is Predictable. (However, if you use Visual Studio to convert a Web project to ASP.NET 4 from an earlier version, Visual Studio automatically sets the site default to AutoID in the Web.config file.)
You can set the `ClientIDMode` value for all pages in a Web site by setting the [pages](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/950xf363(v=vs.100)) element in the site's Web.config file. You can set the `ClientIDMode` value for a page in the [@ Page](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/ydy4x04a(v=vs.100)) directive.
For more information, see [ASP.NET Web Server Control Identification](https://learn.microsoft.com/previous-versions/1d04y8ss(v=vs.140)).
## Examples
The following example shows <xref:System.Web.UI.WebControls.Label> controls that are contained in a <xref:System.Web.UI.WebControls.ListView> control. On the <xref:System.Web.UI.WebControls.ListView> control, the <xref:System.Web.UI.Control.ClientIDMode%2A> property is set to Predictable and the <xref:System.Web.UI.WebControls.ListView.ClientIDRowSuffix%2A> property is set to `ProductID`. From client script, you can access a particular instance of a <xref:System.Web.UI.WebControls.Label> based on the `ProductID` value of the instance that you are trying to access.
This example creates HTML with three `ProductIDLabel` controls. When the page runs, the IDs for the controls will be the following:
- `ListView1_ProductIDLabel_1`
- `ListView1_ProductIDLabel_34`
- `ListView1_ProductIDLabel_43`
:::code language="aspx-csharp" source="~/snippets/common/VS_Snippets_WebNet/system.web.ui.clientidmode/common/predictable.aspx" id="Snippet11":::
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.Control.ClientIDMode" />
<altmember cref="P:System.Web.UI.HierarchicalDataSourceControl.ClientIDMode" />
<altmember cref="P:System.Web.Configuration.PagesSection.ClientIDMode" />
<altmember cref="P:System.Web.UI.DataSourceControl.ClientIDMode" />
<altmember cref="P:System.Web.DynamicData.DynamicDataManager.ClientIDMode" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/1d04y8ss(v=vs.140)">ASP.NET Control Identification</related>
<related type="Article" href="https://learn.microsoft.com/previous-versions/dd410598(v=vs.140)">How to: Access Controls from JavaScript by ID</related>
<related type="Article" href="https://learn.microsoft.com/previous-versions/dd381611(v=vs.140)">Walkthrough: Making Data-Bound Controls Easier to Access from JavaScript</related>
<related type="Article" href="https://learn.microsoft.com/previous-versions/dd483476(v=vs.140)">Walkthrough: Making Controls Located in Web User Controls Easier to Access From JavaScript</related>
</Docs>
<Members>
<Member MemberName="AutoID">
<MemberSignature Language="C#" Value="AutoID" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Web.UI.ClientIDMode AutoID = int32(1)" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.ClientIDMode.AutoID" />
<MemberSignature Language="VB.NET" Value="AutoID" />
<MemberSignature Language="F#" Value="AutoID = 1" Usage="System.Web.UI.ClientIDMode.AutoID" />
<MemberSignature Language="C++ CLI" Value="AutoID" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.ClientIDMode</ReturnType>
</ReturnValue>
<MemberValue>1</MemberValue>
<Docs>
<summary>The <see cref="P:System.Web.UI.Control.ClientID" /> value is generated by concatenating the <see cref="P:System.Web.UI.Control.ID" /> values of each parent naming container with the <see cref="P:System.Web.UI.Control.ID" /> value of the control. In data-binding scenarios where multiple instances of a control are rendered, an incrementing value is inserted in front of the control's <see cref="P:System.Web.UI.Control.ID" /> value. Each segment is separated by an underscore character (_). This algorithm is the only one that was available in versions of ASP.NET earlier than ASP.NET 4.</summary>
</Docs>
</Member>
<Member MemberName="Inherit">
<MemberSignature Language="C#" Value="Inherit" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Web.UI.ClientIDMode Inherit = int32(0)" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.ClientIDMode.Inherit" />
<MemberSignature Language="VB.NET" Value="Inherit" />
<MemberSignature Language="F#" Value="Inherit = 0" Usage="System.Web.UI.ClientIDMode.Inherit" />
<MemberSignature Language="C++ CLI" Value="Inherit" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.ClientIDMode</ReturnType>
</ReturnValue>
<MemberValue>0</MemberValue>
<Docs>
<summary>The control inherits the <see cref="T:System.Web.UI.ClientIDMode" /> setting of its <see cref="P:System.Web.UI.Control.NamingContainer" /> control.</summary>
</Docs>
</Member>
<Member MemberName="Predictable">
<MemberSignature Language="C#" Value="Predictable" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Web.UI.ClientIDMode Predictable = int32(2)" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.ClientIDMode.Predictable" />
<MemberSignature Language="VB.NET" Value="Predictable" />
<MemberSignature Language="F#" Value="Predictable = 2" Usage="System.Web.UI.ClientIDMode.Predictable" />
<MemberSignature Language="C++ CLI" Value="Predictable" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.ClientIDMode</ReturnType>
</ReturnValue>
<MemberValue>2</MemberValue>
<Docs>
<summary>This algorithm is used for controls that are in data-bound controls. The <see cref="P:System.Web.UI.Control.ClientID" /> value is generated by concatenating the <see cref="P:System.Web.UI.Control.ClientID" /> value of the parent naming container with the <see cref="P:System.Web.UI.Control.ID" /> value of the control. If the control is a data-bound control that generates multiple rows, the value of the data field specified in the <see cref="P:System.Web.UI.WebControls.IDataBoundListControl.ClientIDRowSuffix" /> property is added at the end. For the <see cref="T:System.Web.UI.WebControls.GridView" /> control, multiple data fields can be specified. If the <see cref="P:System.Web.UI.WebControls.IDataBoundListControl.ClientIDRowSuffix" /> property is blank, a sequential number is added at the end instead of a data field value. Each segment is separated by an underscore character (_).</summary>
</Docs>
</Member>
<Member MemberName="Static">
<MemberSignature Language="C#" Value="Static" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Web.UI.ClientIDMode Static = int32(3)" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.ClientIDMode.Static" />
<MemberSignature Language="VB.NET" Value="Static" />
<MemberSignature Language="F#" Value="Static = 3" Usage="System.Web.UI.ClientIDMode.Static" />
<MemberSignature Language="C++ CLI" Value="Static" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.ClientIDMode</ReturnType>
</ReturnValue>
<MemberValue>3</MemberValue>
<Docs>
<summary>The <see cref="P:System.Web.UI.Control.ClientID" /> value is set to the value of the <see cref="P:System.Web.UI.Control.ID" /> property. If the control is a naming container, the control is used as the top of the hierarchy of naming containers for any controls that it contains.</summary>
</Docs>
</Member>
</Members>
</Type>