I have been working with blazor in a practical way watching a tutorial. When I added the new option TO TWO and changed the titles to the view everything worked fine.
Now, when I started to touch the view a little more adding more features, when I reload the view, it doesn't reflect the changes.
It should be noted that the IDE does not show me errors or warnings, I did the tutorial several times to read letter by letter in case I have errors, I do not, and I cannot find the solution.
I tried deleting the Bin and OBJ folders but it doesn't work.
This is a snippet of the default NavMenu.Razor document which is where I add the To Dos option to the view
<div class="nav-item px-3">
<NavLink class="nav-link" href="todo">
<span class="oi oi-pencil" aria-hidden="true"></span> To Dos
</NavLink>
</div>
My Razor doc I created:
`@page "/todo"`
> <PageTitle>Mis To Dos</PageTitle>
> <h1>To Dos Pendientes: (@toDos.Count(todo => !todo.EstaCompletado))</h1>
<table>
<thead class= "py-5">
<th class="col-lg-3">Completado?</th>
<th class="col-lg-3">Titulo</th>
<th class="col-lg-3">Contenido</th>
<th class="col-lg-3">Fecha de Entrega</th>
</thead>
@foreach(var toDo in toDos)
{
<tr>
<td><input type="checkbox" @bind="toDo.EstaCompletado"/></td>
<td>@toDo.Titulo</td>
<td>@toDo.Contenido</td>
<td>@toDo.FechaEntrega</td>
</tr>
}
</table>
<h2>Añade Nuevos To Dos</h2>
<input placeholder="Añadir Titulo" @bind = "nuevoTitulo"/>
<input placeholder="Añadir Contenido" @bind="nuevoContenido" />
<button @onclick= AddToDo >Añadir To Do</button>
@code
{
private string? nuevoTitulo;
private string? nuevoContenido;
private List<ToDoItem> toDos = new();
private void AddToDo()
{
// Añade el To Do
if(!string.IsNullOrWhiteSpace(nuevoTitulo))
{
toDos.Add(new ToDoItem {
Titulo = nuevoTitulo,
Contenido = nuevoContenido ,
FechaEntrega = new DateOnly(2022,1,31)
});
nuevoTitulo = string.Empty;
}
}
}
My class that is used for the above:
public class ToDoItem
{
public int TodoItemId { get; set; }
public string? Titulo { get; set; }
public string? Contenido { get; set; }
public string? Responsable { get; set; }
public List<string> Etiquetas { get; set; } = new List<string>();
public DateOnly? FechaEntrega { get; set; }
public TimeOnly? HoraEntrega { get; set; }
public bool EstaCompletado { get; set; } = false;
}
This is the App.razor document that contains that error. I'll leave the coding in case it helps.
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>