Skip to content

Commit e7bb12e

Browse files
authored
Update CustomForm.razor
1 parent bdbcfc1 commit e7bb12e

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

SyncfusionBlazorHybridApp/Pages/CustomForm.razor

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
@using System.ComponentModel.DataAnnotations;
1+
@using System.ComponentModel.DataAnnotations;
22

33
<h2>Customer Registration Form</h2>
44

5-
<EditForm Model="@CustomerDetails" OnValidSubmit="@HandleValidSubmit">
5+
<EditForm Model="@_customerDetails" OnValidSubmit="@HandleValidSubmit">
66
<DataAnnotationsValidator />
77
<div class="row">
88
<div class="col-md-6">
99
<label class="form-label">First Name :</label>
10-
<SfTextBox @bind-Value="@CustomerDetails.FirstName"></SfTextBox>
11-
<ValidationMessage For="@(() => CustomerDetails.FirstName)"></ValidationMessage>
10+
<SfTextBox @bind-Value="@_customerDetails.FirstName"></SfTextBox>
11+
<ValidationMessage For="@(() => _customerDetails.FirstName)"></ValidationMessage>
1212
</div>
1313
<div class="col-md-6">
1414
<label class="form-label">Last Name :</label>
15-
<SfTextBox @bind-Value="@CustomerDetails.LastName"></SfTextBox>
16-
<ValidationMessage For="@(() => CustomerDetails.LastName)"></ValidationMessage>
15+
<SfTextBox @bind-Value="@_customerDetails.LastName"></SfTextBox>
16+
<ValidationMessage For="@(() => _customerDetails.LastName)"></ValidationMessage>
1717
</div>
1818
</div>
1919
<div class="row">
2020
<div class="col-md-6">
2121
<label class="form-label">Gender :</label>
22-
<SfComboBox TValue="string" TItem="Gender" @bind-Value="@CustomerDetails.Gender" DataSource="@Genders">
22+
<SfComboBox TValue="string" TItem="Gender" @bind-Value="@_customerDetails.Gender" DataSource="@_genders">
2323
<ComboBoxFieldSettings Text="Name" Value="Code"></ComboBoxFieldSettings>
2424
</SfComboBox>
25-
<ValidationMessage For="@(() => CustomerDetails.Gender)"></ValidationMessage>
25+
<ValidationMessage For="@(() => _customerDetails.Gender)"></ValidationMessage>
2626
</div>
2727
<div class="col-md-6">
2828
<label class="form-label">Date of Birth :</label>
29-
<SfDatePicker @bind-Value="@CustomerDetails.DateOfBirth"></SfDatePicker>
30-
<ValidationMessage For="@(() => CustomerDetails.DateOfBirth)"></ValidationMessage>
29+
<SfDatePicker @bind-Value="@_customerDetails.DateOfBirth"></SfDatePicker>
30+
<ValidationMessage For="@(() => _customerDetails.DateOfBirth)"></ValidationMessage>
3131
</div>
3232
</div>
3333
<div class="row">
3434
<div class="col-md-9">
3535
<label class="form-label">Email ID :</label>
36-
<SfTextBox @bind-Value="@CustomerDetails.Email"></SfTextBox>
37-
<ValidationMessage For="@(() => CustomerDetails.Email)"></ValidationMessage>
36+
<SfTextBox @bind-Value="@_customerDetails.Email"></SfTextBox>
37+
<ValidationMessage For="@(() => _customerDetails.Email)"></ValidationMessage>
3838
</div>
3939
<div class="col-md-3">
4040
<label class="form-label">Phone Number :</label>
41-
<SfTextBox @bind-Value="@CustomerDetails.PhoneNumber"></SfTextBox>
42-
<ValidationMessage For="@(() => CustomerDetails.PhoneNumber)"></ValidationMessage>
41+
<SfTextBox @bind-Value="@_customerDetails.PhoneNumber"></SfTextBox>
42+
<ValidationMessage For="@(() => _customerDetails.PhoneNumber)"></ValidationMessage>
4343
</div>
4444
</div>
4545
<div class="row">
4646
<div class="col-md-12">
4747
<label class="form-label">Address :</label>
48-
<SfTextBox Multiline=true @bind-Value="@CustomerDetails.Address"></SfTextBox>
49-
<ValidationMessage For="@(() => CustomerDetails.Address)"></ValidationMessage>
48+
<SfTextBox Multiline=true @bind-Value="@_customerDetails.Address"></SfTextBox>
49+
<ValidationMessage For="@(() => _customerDetails.Address)"></ValidationMessage>
5050
</div>
5151
</div>
5252
<div class="row">
5353
<div class="col-md-6">
5454
<label class="form-label">Password :</label>
55-
<SfTextBox @bind-Value="@CustomerDetails.Password"></SfTextBox>
56-
<ValidationMessage For="@(() => CustomerDetails.Password)"></ValidationMessage>
55+
<SfTextBox @bind-Value="@_customerDetails.Password"></SfTextBox>
56+
<ValidationMessage For="@(() => _customerDetails.Password)"></ValidationMessage>
5757
</div>
5858
<div class="col-md-6">
5959
<label class="form-label">Confirm Password :</label>
60-
<SfTextBox @bind-Value="@CustomerDetails.ConfirmPassword"></SfTextBox>
61-
<ValidationMessage For="@(() => CustomerDetails.ConfirmPassword)"></ValidationMessage>
60+
<SfTextBox @bind-Value="@_customerDetails.ConfirmPassword"></SfTextBox>
61+
<ValidationMessage For="@(() => _customerDetails.ConfirmPassword)"></ValidationMessage>
6262
</div>
6363
</div>
6464
<div class="row">
@@ -69,8 +69,8 @@
6969
</EditForm>
7070

7171
@code {
72-
private Customer CustomerDetails;
73-
private List<Gender> Genders;
72+
private Customer _customerDetails;
73+
private List<Gender> _genders;
7474

7575
// Handle form submission
7676
private void HandleValidSubmit()
@@ -80,8 +80,8 @@
8080

8181
protected override void OnInitialized()
8282
{
83-
CustomerDetails = new Customer();
84-
Genders = new Gender().GetGender();
83+
_customerDetails = new Customer();
84+
_genders = new Gender().GetGender();
8585
}
8686

8787
// Data model class
@@ -108,7 +108,7 @@
108108
[Required(ErrorMessage = "Gender is required")]
109109
public string Gender { get; set; }
110110

111-
[Required(ErrorMessage = "PhoneNumber is required")]
111+
[Required(ErrorMessage = "Phone number is required")]
112112
[DataType(DataType.PhoneNumber)]
113113
[Phone]
114114
public string PhoneNumber { get; set; }
@@ -126,7 +126,7 @@
126126
public string ConfirmPassword { get; set; }
127127
}
128128

129-
// Combobx options class
129+
// Combobox options class
130130
public class Gender
131131
{
132132
// Properties for gender options
@@ -136,13 +136,13 @@
136136
// Method for gender options
137137
public List<Gender> GetGender()
138138
{
139-
List<Gender> Gender = new List<Gender>
139+
List<Gender> genders = new List<Gender>
140140
{
141141
new Gender() { Name = "Male", Code = "M" },
142142
new Gender() { Name = "Female", Code = "F" },
143143
new Gender() { Name = "Other", Code = "O" },
144144
};
145-
return Gender;
145+
return genders;
146146
}
147147
}
148148
}

0 commit comments

Comments
 (0)