etienne_marais
Honorary Master
I am following an udemy course and am having trouble at a section where css is used to append text (an asterisk after a label).
The razor page (pages/Register.razor) is as follow:
And the css (pages/Register.razor.css)
The page loads as follow (no asterisk after username or password)

The tutorial project otherwise works exactly as expected with the css addition the latest change to the project.
Any ideas why the asterisks are not showing ?
The razor page (pages/Register.razor) is as follow:
Code:
@page "/register"
@inject IUnitService UnitService
<h3>Register</h3>
<EditForm Model="user" OnValidSubmit="HandleRegistration">
<DataAnnotationsValidator></DataAnnotationsValidator>
<div class="form-group">
<label for="email">Email</label>
<InputText id="email" @bind-Value="user.Email" class="form-control"></InputText>
<ValidationMessage For="@(()=>user.Email)"></ValidationMessage>
</div>
<div class="form-group">
<label for="username" class="required">Username</label>
<InputText id="username" @bind-Value="user.Username" class="form-control"></InputText>
<ValidationMessage For="@(()=>user.Username)"></ValidationMessage>
</div>
<div class="form-group">
<label for="password" class="required">Password</label>
<InputText id="password" @bind-Value="user.Password" class="form-control" type="password"></InputText>
<ValidationMessage For="@(()=>user.Password)"></ValidationMessage>
</div>
<div class="form-group">
<label for="confirmPassword">Confirm Password</label>
<InputText id="confirmPassword" @bind-Value="user.ConfirmPassword" class="form-control" type="password"></InputText>
<ValidationMessage For="@(()=>user.ConfirmPassword)"></ValidationMessage>
</div>
<div class="form-group">
<label for="bio">Bio</label>
<InputTextArea id="bio" @bind-Value="user.Bio" class="form-control"></InputTextArea>
</div>
<div class="form-group">
<label for="startUnit">Start Unit</label>
<InputSelect id="startUnit" @bind-Value="user.StartUnitId" class="form-control">
@foreach (var unit in UnitService.Units)
{
<option value="@unit.Id">@unit.Title</option>
}
</InputSelect>
</div>
<div class="form-group">
<label for="bananas">Bananas</label>
<InputNumber id="bananas" @bind-Value="user.Bananas" class="form-control"></InputNumber>
<ValidationMessage For="@(() => user.Bananas)"></ValidationMessage>
</div>
<div class="form-group">
<label for="dateOfBirth">Date Of Birth</label>
<InputDate id="dateOfBirth" @bind-Value="user.DateOfBirth" class="form-control"></InputDate>
</div>
<div class="form-check">
<InputCheckbox id="confirmed" @bind-Value="@user.IsConfirmed" class="form-check-input"></InputCheckbox>
<label for="confirmed" class="form-check-label">Confirmed</label>
<ValidationMessage For="@(()=>user.IsConfirmed)"></ValidationMessage>
<button type="submit" class="btn btn-primary">Register</button>
</div>
</EditForm>
@code {
UserRegistration user = new UserRegistration();
private void HandleRegistration()
{
Console.WriteLine("Registering");
}
}
And the css (pages/Register.razor.css)
Code:
.required::after {
content: " *";
font-weight: bold;
color: red;
}
The page loads as follow (no asterisk after username or password)

The tutorial project otherwise works exactly as expected with the css addition the latest change to the project.
Any ideas why the asterisks are not showing ?