js files are needed only when using ajax post
The detail-form tag helper renders a single data item both in edit and display mode with a default template that may be customized. It is very usefull for rapid prototyping, since it saves all time needed to write Html and Css details. Default row template renders a Bootstrap form (when in display mode a Bootstrap form in display mode) assigning to each field a number of grid system slots computed from the desired percentage width of the column describing the field.
detail-form supports multiple rows and toolbars.
As for all row based controls
row-type 0 settings are provided in the
tag itself since the
detail-form tag inherits from the
row-type tag helper.
Default layout template in edit mode includes also the form to submit all changes. It includes also
LayoutStandardPlaces.HeaderEdit toolbar zone
(toolbars with both names are placed in the same zone), a
LayoutStandardPlaces.SubmitBar toolbar zone, and
LayoutStandardPlaces.FooterEdit toolbar zone. Display mode has a
(toolbars with both names are placed in the same zone) and a
Submitbar is intended for placing custom submit/reset buttons, so when no submitbar is found
either a submit (if standard post has been specified) or a save (if ajax submit has been specified) button is automatically added.
Please refer to the buttons documentation for more
save buttons and buttons in general.
detail-form tag helper attributesdetail-form tag helper inherits all
row-type attributesthat are used to define the main row-type (0 index row-type). Below all additional attributes.
- asp-for: ModelExpression
- The property to render with the detail-form.
- edit-mode: ModelExpression, edit-mode-default: bool
Two ways to specify if the control is in edit mode: as a constant, or in the View model. For server controls
edit-mode-defaultsuffices for both purposes, but for client controls where model is on the client side this is not the case.
- id: string
- The id that is placed in the root Html node is computed automatically, based on the path from the ViewModel to the property being rendered with the detail-form. If this attribute is specified, it overrides the automatically computed id.
- class: string
- Space separated Css classes placed ith the detail-form root node.
- ServerRowSelection : Func<object, int>
A function that, evaluated on the data item, returns the index of the
row-typeto use for rendering that data item. As a default
row-typeis chosen based on the run time data item type as explained in the row-type documentation.
- client-row-selection : string
Used for client controls implementations of the detail-form(ie with tag helper providers whose detail-forms create their Html on the client side).
ServerRowSelectionon the client side.
- model-null-row : ModelExpression, model-null-row-default: int
Used when model is null, so it cannot be used to decide which
row-typeto use for rendering. This happens during new item creation, so it is obvious, that in this case we need to specify the kind of data item to create. Two ways to specify the index of the
row-typeto use for rendering the null model: as a constant, or in the View model. For server controls
model-null-row-defaultsuffices for both purposes, but for client controls where model is on the client side this is not the case.
- form-action : string
- Url where to submit the form when in edit mode
- form-method : string
- Verb to submit the form with when in edit mode (It defaults to "POST").
- asp-antiforgery : bool?
- If provided and set, automatically adds an antiforgery hidden field.
- no-submit : bool
- If set, selects post based ajax form submit. In this case if no submitbar is provided the button added is a save button that automatically triggers the ajax submit.
- rows-cache-key: string
When a name is specified all
row-typedefinition settings are cached to save the time needed to parse and process all
row-typetag helpers. Cached settings are used by all controls that specify the same
- layout-template: string
- The name of a partial view providing a custom layout template.