You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/DataControls/DataList.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ The DataList component is meant to emulate the asp:DataList control in markup an
28
28
-`EnableViewState`
29
29
-`ID` should be converted to `@ref` if the component is referenced in code
30
30
-`ItemType` MUST be defined as an attribute
31
-
-`Context` should be used to define the object used in templates. If not defined, the default `<INSERT>` will be available.
31
+
-**For Web Forms compatibility, use `Context="Item"`**to access the current data item in templates with the name `@Item` instead of Blazor's default `@context`
Copy file name to clipboardExpand all lines: docs/DataControls/FormView.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ The FormView component is meant to emulate the asp:FormView control in markup an
10
10
11
11
## Usage Notes
12
12
13
+
-**ItemType attribute** - Required to specify the type of items in the collection
14
+
-**Context attribute** - For Web Forms compatibility, use `Context="Item"` to access the current item as `@Item` in templates (ItemTemplate, EditItemTemplate, InsertItemTemplate) instead of Blazor's default `@context`
15
+
-**ID** - Use `@ref` instead of `ID` when referencing the component in code
Copy file name to clipboardExpand all lines: docs/DataControls/GridView.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ The GridView component is meant to emulate the asp:GridView control in markup an
8
8
### Blazor Notes
9
9
10
10
- The `RowCommand.CommandSource` object will be populated with the `ButtonField` object
11
+
-**Context attribute** - When using `<TemplateField>`, add `Context="Item"` to access the current row item as `@Item` instead of Blazor's default `@context`
Copy file name to clipboardExpand all lines: docs/DataControls/ListView.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,9 @@ The ListView component is meant to emulate the asp:ListView control in markup an
21
21
22
22
## Usage Notes
23
23
24
-
- LayoutTemplate requires a `Context` attribute that defines the placeholder for the items
24
+
-**LayoutTemplate** - Requires a `Context` attribute that defines the placeholder for the items
25
+
-**Context attribute** - For Web Forms compatibility, use `Context="Item"` on the ListView to access the current item as `@Item` in ItemTemplate and AlternatingItemTemplate instead of Blazor's default `@context`
26
+
-**ItemType attribute** - Required to specify the type of items in the collection
Copy file name to clipboardExpand all lines: docs/DataControls/Repeater.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,3 +39,29 @@ The Repeater component is meant to emulate the asp:Repeater control in markup an
39
39
</SeparatorTemplate>
40
40
</asp:Repeater>
41
41
```
42
+
43
+
## Usage Notes
44
+
45
+
-**ItemType attribute** - Required to specify the type of items in the collection
46
+
-**Context attribute** - For Web Forms compatibility, use `Context="Item"` to access the current item as `@Item` in templates instead of Blazor's default `@context`
47
+
-**ID** - Use `@ref` instead of `ID` when referencing the component in code
48
+
-**runat** and **EnableViewState** - Not used in Blazor (these attributes are ignored)
Copy file name to clipboardExpand all lines: docs/Migration/migration_readiness.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,11 @@ Throughout this document, we will refer to several framework and technology term
20
20
- Class libraries referenced need to be convertible to .NET Standard
21
21
- No 3rd party control libraries that don't have a shim for conversion (none available at the time of this writing)
22
22
23
+
### Data-Bound Controls
24
+
25
+
- For data-bound controls (Repeater, DataList, GridView, ListView, FormView), use `Context="Item"` attribute to access items with `@Item` instead of Blazor's default `@context`
26
+
- This provides compatibility with Web Forms' strongly-typed `Item` property when using `ItemType` attribute
27
+
23
28
## Application architecture suggestions
24
29
25
30
- Prefer model-binding techniques over handling Form life-cycle events like `Init`, `Load`, `PreRender`, and `Unload`
Copy file name to clipboardExpand all lines: docs/Migration/readme.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,41 @@ Alternatively, you can add the script manually to your layout:
113
113
114
114
For more options and details, see the [JavaScript Setup documentation](../UtilityFeatures/JavaScriptSetup.md).
115
115
116
+
## Step 5.6 - Data-Bound Controls and Template Context
117
+
118
+
When migrating data-bound controls like `<asp:Repeater>`, `<asp:DataList>`, `<asp:GridView>`, `<asp:ListView>`, and `<asp:FormView>`, you'll encounter a key difference in how templates access the current data item.
119
+
120
+
### Web Forms vs. Blazor Context
121
+
122
+
In ASP.NET Web Forms, when using strongly-typed data-binding with the `ItemType` attribute, templates access the current item using the `Item` property. In Blazor, templated components use a context variable.
123
+
124
+
**Blazor's Default Behavior:**
125
+
By default, Blazor uses `@context` as the variable name inside templates:
126
+
127
+
```razor
128
+
<Repeater Items="widgets" ItemType="Widget">
129
+
<ItemTemplate>@context.Name</ItemTemplate>
130
+
</Repeater>
131
+
```
132
+
133
+
**Web Forms Compatibility:**
134
+
For better compatibility with Web Forms conventions and to reduce migration friction, **use the `Context="Item"` attribute** on data-bound components. This allows you to use `@Item` (similar to Web Forms' `Item` property):
-`<GridView>` with `<TemplateField>` - ItemTemplate
148
+
149
+
**Note:** While it's one extra attribute per component, using `Context="Item"` eliminates the need to learn Blazor-specific `@context` syntax and makes your templates more readable for developers familiar with Web Forms.
150
+
116
151
## Step 6 - Pages
117
152
118
153
Page migration is a process very similar to UserControls, except working on files with the `.aspx` extension.
0 commit comments