Table of Contents

Class ValidateForm

Namespace
BootstrapBlazor.Components
Assembly
BootstrapBlazor.dll

ValidateForm 组件类

public class ValidateForm : BootstrapModuleComponentBase, IComponent, IHandleAfterRender, IHandleEvent, IAsyncDisposable
Inheritance
ValidateForm
Implements
Inherited Members
Extension Methods

Constructors

ValidateForm()

public ValidateForm()

Properties

ChildContent

Specifies the content to be rendered inside this

[Parameter]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

DisableAutoSubmitFormByEnter

获得/设置 是否禁用表单内回车自动提交功能 默认 null 未设置

[Parameter]
public bool? DisableAutoSubmitFormByEnter { get; set; }

Property Value

bool?

Model

Specifies the top-level model object for the form. An edit context will be constructed for this model. If using this parameter, do not also supply a value for EditContext.

[Parameter]
public object? Model { get; set; }

Property Value

object

OnFieldValueChanged

A callback that will be invoked when the field's value has been changed

[Parameter]
public Action<string, object?>? OnFieldValueChanged { get; set; }

Property Value

Action<string, object>

OnInvalidSubmit

A callback that will be invoked when the form is submitted and the EditContext is determined to be invalid.

[Parameter]
public Func<EditContext, Task>? OnInvalidSubmit { get; set; }

Property Value

Func<EditContext, Task>

OnValidSubmit

A callback that will be invoked when the form is submitted and the EditContext is determined to be valid.

[Parameter]
public Func<EditContext, Task>? OnValidSubmit { get; set; }

Property Value

Func<EditContext, Task>

ShowLabel

获得/设置 是否显示验证表单内的 Label 默认为 显示

[Parameter]
public bool ShowLabel { get; set; }

Property Value

bool

ShowLabelTooltip

获得/设置 是否显示标签 Tooltip 多用于标签文字过长导致裁减时使用 默认 null

[Parameter]
public bool? ShowLabelTooltip { get; set; }

Property Value

bool?

ShowRequiredMark

获得/设置 是否获取必填项标记 默认为 true 显示

[Parameter]
public bool ShowRequiredMark { get; set; }

Property Value

bool

ValidateAllProperties

获得/设置 是否验证所有字段 默认 false

[Parameter]
public bool ValidateAllProperties { get; set; }

Property Value

bool

ValueChagnedFields

获取 当前表单值改变的属性集合

[Obsolete("已过期,单词拼写错误,请使用 ValueChangedFields,Please use ValueChangedFields instead. wrong typo")]
public ConcurrentDictionary<FieldIdentifier, object?> ValueChagnedFields { get; }

Property Value

ConcurrentDictionary<FieldIdentifier, object>

ValueChangedFields

获取 当前表单值改变的属性集合

public ConcurrentDictionary<FieldIdentifier, object?> ValueChangedFields { get; }

Property Value

ConcurrentDictionary<FieldIdentifier, object>

Methods

BuildRenderTree(RenderTreeBuilder)

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

NotifyFieldChanged(in FieldIdentifier, object?)

通知属性改变方法

public void NotifyFieldChanged(in FieldIdentifier fieldIdentifier, object? value)

Parameters

fieldIdentifier FieldIdentifier
value object

OnParametersSet()

OnParametersSet 方法

protected override void OnParametersSet()

SetError(string, string)

设置指定字段错误信息

public void SetError(string propertyName, string errorMessage)

Parameters

propertyName string

字段名,可以使用多层,如 a.b.c

errorMessage string

错误描述信息,可为空,为空时查找资源文件

SetError<TModel>(Expression<Func<TModel, object?>>, string)

设置指定字段错误信息

public void SetError<TModel>(Expression<Func<TModel, object?>> expression, string errorMessage)

Parameters

expression Expression<Func<TModel, object>>
errorMessage string

错误描述信息,可为空,为空时查找资源文件

Type Parameters

TModel

Validate()

验证方法 用于代码调用触发表单验证

public bool Validate()

Returns

bool