Skip to content

RedText template renamed to UnitsInStock #7516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions xml/System.ComponentModel.DataAnnotations/UIHintAttribute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,23 @@
<format type="text/markdown"><![CDATA[

## Remarks
ASP.NET Dynamic Data provides field templates and page templates for rendering data fields in a data model. Field templates are user controls (.ascx files) that are mapped to data fields in the model. You can modify the default user controls that Dynamic Data provides, or you can create a custom user controls to use as field template. If you create a custom user control, you use the <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property on a property so that the property is rendered using the custom user control. The <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property specifies which field template to use when a specific column is rendered. The <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property can point to one of the templates provided in Dynamic Data or to a custom template. For example, you can create a custom field template named RedText_Edit.ascx, and then use the <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property to specify that the RedText_Edit.ascx control should be used to render a specified data field instead of the default Text_Edit.ascx template that is provided in Dynamic Data.
ASP.NET Dynamic Data provides field templates and page templates for rendering data fields in a data model.
Field templates are user controls (`.ascx` files for **MVC**, `.cshtml` files for **Razor**) that are mapped to data fields in the model.
You can modify the default user controls that Dynamic Data provides, or you can create a custom user controls to use as field template.
Having created a custom user control,
use the <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property on a property
so that the property will be rendered using your custom user control.
The <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property
specifies which field template to use when a specific column is rendered.
The <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property
can point to one of the templates provided in Dynamic Data or to a custom template.
For example, you can create custom field templates named `UnitsInStock.ascx` and `UnitsInStock_Edit.ascx`
and then use the <xref:System.ComponentModel.DataAnnotations.UIHintAttribute.UIHint%2A> property
to specify that the `UnitsInStock` control should be used to render a specified data field
instead of the default `Text` template that is provided in Dynamic Data.

The following example shows how to specify that the UnitsInStock column in a database will be rendered by using the specified custom field template.
The following example shows how to specify
that the `UnitsInStock` column in a database will be rendered by using the specified custom field template.

:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_WebNet/DynamicData.CustomFieldTemplate/CS/Product.cs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_WebNet/DynamicData.CustomFieldTemplate/VB/Products.vb" id="Snippet5":::
Expand Down