/
ValidationTest.razor
64 lines (54 loc) · 1.85 KB
/
ValidationTest.razor
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
@page "/validationtest"
@using Blazor.AppTest.Data
<EditForm Model="@exampleModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
@* <ValidationSummary />*@
<div class="form-group row">
<label for="Name" class="col-sm-2 col-form-label">
Name
</label>
<div class="col-sm-10">
@*<InputText id="Name" class="form-control" placeholder="Name"
@bind-Value="exampleModel.Name" />*@
<OnInputEventInputText id="Name" class="form-control" placeholder="Name"
@bind-Value="exampleModel.Name" />
<ValidationMessage For="@(() => exampleModel.Name)" />
</div>
</div>
<div class="form-group row">
<label for="Age" class="col-sm-2 col-form-label">
Age
</label>
<div class="col-sm-10">
<InputNumber id="Age" class="form-control" placeholder="Age"
@bind-Value="exampleModel.Age" />
<ValidationMessage For="@(() => exampleModel.Age)" />
</div>
</div>
<div class="form-group row">
<label for="gender" class="col-sm-2 col-form-label">
Gender
</label>
<div class="col-sm-10">
<InputSelect @bind-Value="exampleModel.Gender" class="form-control">
@foreach (var gender in Enum.GetValues(typeof(Gender)))
{
<option value="@gender">@gender</option>
}
</InputSelect>
</div>
</div>
<br /><br />
<button type="submit">Submit</button>
</EditForm>
@code {
private ExampleModel exampleModel = new();
protected override void OnInitialized()
{
base.OnInitialized();
}
private void HandleValidSubmit()
{
Console.WriteLine("HandleValidSubmit");
}
}